Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 06-11-2014, 12:56 PM   #1
LQ Newbie
Registered: Jun 2014
Posts: 3

Rep: Reputation: Disabled
Cool 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:

echo "Waiting for IP on WANUP" >> /opt/logs/debug.log
while [ $x -lt 30 ]; do
sleep 2
echo "Retries:$x/30; IP: $(curl -s" >> /opt/logs/debug.log
let x=x=1
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

Any ideas how to fix the curl -s
part so I get the IP address on startup properly. ?
Old 06-11-2014, 02:49 PM   #2
Senior Member
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 (pre-systemd)
Posts: 2,855

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
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.
Old 06-11-2014, 03:07 PM   #3
LQ Newbie
Registered: Jun 2014
Posts: 3

Original Poster
Rep: Reputation: Disabled
yes there was a typo which stops the counter incrementing, wasnt
able to paste back from typed in manually.

And guess what.. now it works ..!

Very much appreciated from this side of the pond


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash script - command works directly in command line but not in script raoulcousins Linux - Newbie 6 08-21-2013 08:43 PM
Startup Script I wrote for Wireless -works on slackware The Gargantuan Linux - Software 1 07-21-2010 03:47 PM
Bash/Mutt/Abook (no X): Any ideas for a birthday remembering email? script? frenchn00b Programming 6 04-22-2009 08:06 AM
Strange script error - any ideas (bash hanging) bagpussnz Linux - General 1 01-30-2009 11:29 PM
Startup script failing at bootup, works when logged on cmowl Linux - Enterprise 1 10-20-2005 11:22 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:40 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration