LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 06-11-2014, 11:56 AM   #1
robinaspey
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:

#!/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. ?
 
Old 06-11-2014, 01:49 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 (pre-systemd)
Posts: 2,749

Rep: Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741
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, 02:07 PM   #3
robinaspey
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 Putty...so typed in manually.

And guess what.. now it works ..!

Very much appreciated from this side of the pond
 
  


Reply


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 07:43 PM
Startup Script I wrote for Wireless -works on slackware The Gargantuan Linux - Software 1 07-21-2010 02:47 PM
Bash/Mutt/Abook (no X): Any ideas for a birthday remembering email? script? frenchn00b Programming 6 04-22-2009 07:06 AM
Strange script error - any ideas (bash hanging) bagpussnz Linux - General 1 01-30-2009 10:29 PM
Startup script failing at bootup, works when logged on cmowl Linux - Enterprise 1 10-20-2005 10:22 PM


All times are GMT -5. The time now is 09:41 AM.

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