Bash script works different as startup script - any ideas ?
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. ? |
Looks like your loop should never end, since x is not incremented.
Most likely curl is not in the script's PATH. Specify the absolute path for all executables: /usr/bin/curl. |
yes there was a typo which stops the counter incrementing, wasnt
able to paste back from Putty...so typed in manually. And guess what.. now it works ..! Very much appreciated from this side of the pond :) |
All times are GMT -5. The time now is 11:10 PM. |