[Linux-ham] linux script thing -- not doing WGET. I'm missing something
Tadd Torborg
tadd at mac.com
Sun Feb 9 03:13:05 EST 2014
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.trilug.org/pipermail/linux-ham/attachments/20140209/cb85d262/attachment-0001.html>
More information about the Linux-ham
mailing list