I am testing a bash shell script which works ok from root login at the command line. The script runs on a DD-WRT linux router and is as follows:
#!/bin/sh
x=0
echo "Waiting for IP on WANUP" >> /opt/logs/debug.log
while [ $x -lt 30 ]; do
sleep 2
echo "Retries:$x/30; IP: $(curl -s http://icanhazip.com)" >> /opt/logs/debug.log
let x=x=1
done
echo "Finished " >> /opt/logs/debug.log
The script has the following name wanup.ipup so that it runs
when the connections comes on. It all works correctly but
for some reason when running as a startup script rather than
from the command line, the curl command returns a null instead
of the WAN IP address
The script was made executable e.g. chmod +x wanup.ipup
and other than the curl part it works find and executes
on startup but the file debug.log reveals no IP addresses
logged.
Any ideas how to fix the curl -s
http://icanhazip.com
part so I get the IP address on startup properly. ?