Tiny Core Linux
Tiny Core Base => TCB Q&A Forum => Topic started by: ambaum01 on January 24, 2013, 12:04:44 PM
-
Hello all,
I'm trying to boot tiny core and scp a file to a server as soon as a network connection is established. My scp code is in a script in bootlocal.sh. If I let that scp code execute too early, it kicks back an error about not being connected to the server and quits the scp. Currently, I have hacked in a sleep 5 to ensure that the connection is made, but I'd rather run a script before the scp script that will ensure there is network connectivity before I try the scp and reduce the time it takes to run. So far, I have written this:
#!/bin/sh
#Pinging the server until it responds
unreachable=1;
while [ $unreachable -ne 0 ]; do
echo are you there?
ping -c 1 -w 1 SERVER &> /dev/null
unreachable=$?
echo sleeping
done
echo awake
The problem I am having is that the ping -w 1 doesn't seem to be working. When I unplug the network cable, it runs through the while loop about every 20 seconds instead of every 1 second like I would expect. I would have thought that with a network cable unplugged, ping would immediately throw and error and exit. Am I incorrect in that assumption? Thanks for all the help.
-Aaron
-
This what I call from bootlocal.sh when I need to be sure the network is up.
tc@box:/opt$ cat waitip
SEC=60
while [ $SEC -gt 0 ] ; do
ifconfig | grep "inet addr:" | grep -qv "127.0.0.1" && break
echo -ne "Waiting for IP $(( SEC--)) \r"
sleep 1
done
echo
-
You could also look at the script that I have in /etc/init.d/settime.sh to set time for machines (arm) with no RTC,
-
You could also look at the script that I have in /etc/init.d/settime.sh to set time for machines (arm) with no RTC,
This is exactly what I needed. Thanks so much!
-Aaron