-1

I`am a beginner in coding so I would ask for help to using this code on raspberry buster in a c program:

ping -c 1 -t 1 192.168.1.1;if [ $? -eq 0 ]; then echo "192.168.1.1 is up"; else echo "ip is down";fi

the code should do 1. if ip is up insert inputs from ig. a keypad to a mysql database 2. if ip is down write the inputs line by line a file

thank you very much for some tips.

1 Answers1

1

To ping yourself, your application would have to create a raw socket, needing the NET_RAW capability. You may have look at the GNU iputils ping implementation for reference: https://sourceforge.net/p/iputils/code/ci/master/tree/ping.c

Most convenient would probably be "Execute ping as a process and parse its exit code".

  • Hi! but i don`t want a lot code, is there an other possibility ? Thank you very much for our answer in advance. – user397897 Mar 02 '20 at 11:57