[Linux-ham] linux script thing -- not doing WGET. I'm missing something

Dave Sorenson sorenson at uffdaa.com
Sun Feb 9 11:11:09 EST 2014


I've found that when a script runs as a process you need to put the full
path to the file you want to manipulate. Even if you specify the paths, for
some reason the automated processes will not respect it. The confusing
thing is, if you run the script as root it works fine. It only fails when
its run via an automated process. Example : rm textfile.txt  will fail.
But, rm /home/myuser/textfile.txt will work. The no such file output
generally  is an indication of this. This might not be all that is tripping
you up, but might help on the file not founds.
On Feb 9, 2014 10:49 AM, "Tadd Torborg" <tadd at mac.com> wrote:

> Oddly, the script runs again if you KILL the linbpq process, and it fails
> again, even though it is long after the boot.
> Dunno.  I suppose what I should do is base the URL on yet another instance
> of the hostname or something else.   The hostname is already specified in
> /etc/hosts and /etc/hostname
>    Tadd
>
> Tadd Torborg
> tadd at mac.com
>
>
>
> On Feb 9, 2014, at 4:42 AM, R Radford <rradford at mindspring.com> wrote:
>
> When in the inittab order is the script run?   Is it possible the network
> interface is not yet up at the time the script is run that way?
>
> Actually I just saw your note about hostname not being configured, which
> matches my thought of the issue - I suspect the network interface and stack
> is not yet up.
>
> Try moving the process to run later in the boot order and see if that
> resolves your issue.
>
>
>
> On Sun, Feb 9, 2014 at 3:13 AM, Tadd Torborg <tadd at mac.com> wrote:
>
>> Raspbian Debian Wheezy
>>
>> I'm looking for help with a bash script, run from /etc/inittab, that
>> doesn't seem to be able to WGET.
>>
>> I'm trying to write a script which will run pilinbpq.  The trick I'm
>> trying to do is that every time the script runs, I want it to do a WGET of
>> the bpq config file from my web server.   It doesn't seem to succeed in
>> doing the WGET from the web page if this is run from /etc/inittab.  But
>> when I test the script it works fine.  HELP?
>>
>> If I run the script as pi, it runs and works.
>> if I run the script after sudo su root, it runs and works.
>> If I let it run at boot from inittab, it does everything except complete
>> the WGET.
>> I tried letting wget run as root and as pi.  That didn't seem to make any
>> difference.
>>
>> Here is the script:
>> SCRIPTFILE_FROM_WEBSERVER="bpq32.txt";
>> SCRIPTLOGFILE="/home/pi/bpq/scriptrun.log";
>> cd /home/pi/bpq;
>> echo "------"          >> $SCRIPTLOGFILE;
>> echo "start of script" >> $SCRIPTLOGFILE;
>> echo "v001"            >> $SCRIPTLOGFILE;
>> date                   >> $SCRIPTLOGFILE;
>> whoami                 >> $SCRIPTLOGFILE;
>> sudo rm bpq32.txt;
>> sudo -u pi wget http://www.torborg.com/bpq/$HOSTNAME/bpq32.txt;
>> if find "$SCRIPTFILE_FROM_WEBSERVER";
>> then
>>   echo "bpq config retrieved from webserver" >> $SCRIPTLOGFILE;
>>   sudo rm bpq32.old;
>>   mv bpq32.cfg bpq32.old;
>>   mv $SCRIPTFILE_FROM_WEBSERVER bpq32.cfg;
>> else
>>   echo "bpq config NOT retrieved from webserver" >> $SCRIPTLOGFILE;
>> fi;
>> echo "launching bpq"      >> $SCRIPTLOGFILE;
>> sudo -u pi mv linbpq.new linbpq:
>> sudo -u pi ./linbpq;
>> echo "end of script"     >> $SCRIPTLOGFILE;
>> *pi at wakde1-ka2dew-3* *~/bpq $*
>>
>>
>>
>> Note that I'm doing a whoami in the script and outputting it to the log
>> file.
>> Here is some of the log file
>> ------
>> start of script
>> v001
>> Sun Feb  9 07:52:05 UTC 2014
>> root
>> bpq config NOT retrieved from webserver
>> launching bpq
>> ------
>> start of script
>> v001
>> Sun Feb  9 08:02:00 UTC 2014
>> pi
>> bpq config retrieved from webserver
>> launching bpq
>> end of script
>> ------
>> start of script
>> v001
>> Sun Feb  9 08:02:28 UTC 2014
>> root
>> bpq config retrieved from webserver
>> launching bpq
>> end of script
>> root at wakde1-ka2dew-3:/home/pi/bpq#
>>
>>
>>
>> The first run was called from /etc/inittab.
>>
>> The second run was from the pi log-in
>>
>> The third run was from sudo su root
>>
>> Here is the screen text from the runs after I reboot after removing the
>> call from inittab.
>> Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
>> permitted by applicable law.
>> Last login: Sun Feb  9 07:44:10 2014 from 10.0.0.179
>> *pi at wakde1-ka2dew-3* *~ $* cd bpq
>> *pi at wakde1-ka2dew-3* *~/bpq $* ./runbpq
>> rm: cannot remove `bpq32.txt': No such file or directory
>> --2014-02-09 08:02:00--
>> http://www.torborg.com/bpq/wakde1-ka2dew-3/bpq32.txt
>> Resolving www.torborg.com (www.torborg.com)... 50.62.116.1
>> Connecting to www.torborg.com (www.torborg.com)|50.62.116.1|:80...
>> connected.
>> HTTP request sent, awaiting response... 200 OK
>> Length: 20118 (20K) [text/plain]
>> Saving to: `bpq32.txt'
>>
>> 100%[==========================================================================================================>]
>> 20,118      --.-K/s   in 0.07s
>>
>> 2014-02-09 08:02:00 (300 KB/s) - `bpq32.txt' saved [20118/20118]
>>
>> bpq32.txt
>> rm: cannot remove `bpq32.old': No such file or directory
>> mv: cannot stat `linbpq.new': No such file or directory
>> G8BPQ AX25 Packet Switch System Version 6.0.5.11 Febuary 2014
>> Copyright ? 2001-2014 John Wiseman G8BPQ
>> Current Directory is /home/pi/bpq
>>
>> Configuration file Preprocessor.
>> Using Configuration file /home/pi/bpq/bpq32.cfg
>> Conversion (probably) successful
>>
>> PORTS 157374 LINKS 15a604 DESTS 15ad2a ROUTES 15de2a L4 15f36a BUFFERS
>> 165328
>>
>> Initialising Port 01     I2C Bus 1 Addr 16 Chan A
>> Initialising Port 02     I2C Bus 1 Addr 17 Chan A
>> Initialising Port 03     AXIP
>> Initialising Port 04     Telnet Server
>> slave device: /dev/pts/1. symlink to /home/pi/com4 created
>> TNC Emulator Init Complete
>> ^Cterminating on SIGINT
>> Closing Ports
>> *pi at wakde1-ka2dew-3* *~/bpq $* sudo su root
>> root at wakde1-ka2dew-3:/home/pi/bpq# ./runbpq
>> rm: cannot remove `bpq32.txt': No such file or directory
>> --2014-02-09 08:02:28--
>> http://www.torborg.com/bpq/wakde1-ka2dew-3/bpq32.txt
>> Resolving www.torborg.com (www.torborg.com)... 50.62.116.1
>> Connecting to www.torborg.com (www.torborg.com)|50.62.116.1|:80...
>> connected.
>> HTTP request sent, awaiting response... 200 OK
>> Length: 20118 (20K) [text/plain]
>> Saving to: `bpq32.txt'
>>
>> 100%[==========================================================================================================>]
>> 20,118      --.-K/s   in 0.06s
>>
>> 2014-02-09 08:02:28 (316 KB/s) - `bpq32.txt' saved [20118/20118]
>>
>> bpq32.txt
>> mv: cannot stat `linbpq.new': No such file or directory
>> G8BPQ AX25 Packet Switch System Version 6.0.5.11 Febuary 2014
>> Copyright ? 2001-2014 John Wiseman G8BPQ
>> Current Directory is /home/pi/bpq
>>
>> Configuration file Preprocessor.
>> Using Configuration file /home/pi/bpq/bpq32.cfg
>> Conversion (probably) successful
>>
>> PORTS 157374 LINKS 15a604 DESTS 15ad2a ROUTES 15de2a L4 15f36a BUFFERS
>> 165328
>>
>> Initialising Port 01     I2C Bus 1 Addr 16 Chan A
>> Initialising Port 02     I2C Bus 1 Addr 17 Chan A
>> Initialising Port 03     AXIP
>> Initialising Port 04     Telnet Server
>> slave device: /dev/pts/1. symlink to /home/pi/com4 created
>> TNC Emulator Init Complete
>> ^Cterminating on SIGINT
>> Closing Ports
>>
>>
>> Here is the ls -l of the /home/pi/bpq directory
>>
>> *pi at wakde1-ka2dew-3* *~/bpq $* ls -l
>> total 2472
>> -rw-r--r-- 1 pi   pi     18253 Feb  5 22:11 2014_02_05_bpq32.cfg
>> -rw-r--r-- 1 pi   pi     20118 Feb  9 06:50 bpq32.cfg
>> -rw-r--r-- 1 pi   pi     20118 Feb  9 06:50 bpq32.old
>> -rw-r--r-- 1 pi   pi        37 Feb  9 08:02 BPQNODES.dat
>> -rw-r--r-- 1 pi   pi       899 Jan 27 02:02 error.txt
>> -rwxr-xr-x 1 pi   pi        56 Jan 27 02:02 *ftp*
>> drwxr-xr-x 2 pi   pi      4096 Jan 26 23:06 *HTML*
>> -rwxr-xr-x 1 pi   pi   2422662 Feb  8 20:28 *linbpq*
>> drwxrwxrwx 2 pi   pi      4096 Feb  5 21:29 logs
>> -rwxr-xr-x 1 pi   pi        25 Feb  9 07:18 *psloop*
>> -rwxr-xr-x 1 pi   pi       810 Feb  9 07:51 *runbpq*
>> -rw-rw-rw- 1 root root    2381 Feb  9 08:02 scriptrun.log
>> -rwxr-xr-x 1 pi   pi       549 Feb  9 07:10 *testwget*
>> -rw-r--r-- 1 pi   pi        48 Feb  8 20:29 update
>> drwxr-xr-x 2 pi   pi      4096 Jan 28 00:02 *works1*
>> *pi at wakde1-ka2dew-3* *~/bpq $*
>>
>> Thanks for any help, questions, or taunts.
>>
>>    Tadd, KA2DEW
>>
>>
>> _______________________________________________
>> Linux-ham mailing list
>> Linux-ham at trilug.org
>> http://www.trilug.org/mailman/listinfo/linux-ham
>>
>>
> _______________________________________________
> Linux-ham mailing list
> Linux-ham at trilug.org
> http://www.trilug.org/mailman/listinfo/linux-ham
>
>
>
> _______________________________________________
> Linux-ham mailing list
> Linux-ham at trilug.org
> http://www.trilug.org/mailman/listinfo/linux-ham
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.trilug.org/pipermail/linux-ham/attachments/20140209/75f6eae0/attachment-0001.html>


More information about the Linux-ham mailing list