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

Tadd Torborg tadd at mac.com
Sun Feb 9 15:52:42 EST 2014


Thanks for the help!
The script appears to be working well now in /etc/inittab.  I added the first line and that took care of it.  I don’t know why.. but all’s well that ends.  
I need to learn about all of the script starter folders.  I have used the cron folders in the past but never did a “respawn” or anything in inittab or if-up.d


This is what it looks like now
#!/bin/bash
SCRIPTFILE_FROM_WEBSERVER="bpq32.txt";
SCRIPTLOGFILE="/home/pi/bpq/scriptrun.log";
cd /home/pi/bpq;
echo "------"             >> $SCRIPTLOGFILE;
echo "start of script"    >> $SCRIPTLOGFILE;
echo "ScriptVersion=007"  >> $SCRIPTLOGFILE;
sleep 2;
echo -n "datetime="       >> $SCRIPTLOGFILE;
date  >> $SCRIPTLOGFILE;
echo "hostname="$HOSTNAME >> $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;


Now I’m working on making a config file parser with sed and bash scripting.  I may have more questions! 
  Tadd

Tadd Torborg
tadd at mac.com

“If you don’t know what you are doing, you best do it quickly”   (quote may have been from duck dynasty)

On Feb 9, 2014, at 11:38 AM, Basil Gunn <basil at pacabunga.com> wrote:

> On Sun, 09 Feb 2014 03:13:05 -0500
> Tadd Torborg <tadd at mac.com> wrote:
> 
>> I'm looking for help with a bash script, run from /etc/inittab, that
>> doesn't seem to be able to WGET.  
>> sudo -u pi wget http://www.torborg.com/bpq/$HOSTNAME/bpq32.txt;
> 
> 3 things I noticed.
> 
> You don't have the first line in your script specifying the SHELL
> interpreter.
> 
> #!/bin/bash
> 
> You are relying on an environment variable HOSTNAME which may not be
> set. Trying using the command hostname instead ie.
> 
> HOST=$(hostname)
> 
> As mentioned by R Radford, since you want this script to run after
> your network is initialized run it from this directory:
> 
> /etc/network/if-up.d/
> 
> /Basil n7nix

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.trilug.org/pipermail/linux-ham/attachments/20140209/37704f9f/attachment.html>


More information about the Linux-ham mailing list