[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bash script calling python script fails



Le 16/06/2015 15:53, tomas@tuxteam.de a écrit :
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, Jun 16, 2015 at 03:01:30PM +0200, rudu wrote:
Le 16/06/2015 12:47, tomas@tuxteam.de a écrit :
On Tue, Jun 16, 2015 at 11:23:51AM +0200, rudu wrote:
Hello,
There's something I just can't figure out :
[...]

Thank you Tomas,
You're right I should have pasted my script in the first place (see below).
By the way, you'll see I already thought about this $PATH thing, but
unless I forgot something that doesn't seem to be the case here.
So, briefly said, that line :
             /usr/bin/python /home/rudu/DynHost/ipcheck.py $OPTIONS
$LOGIN $PASSWORD $HOST >> $THISLOG
runs as expected when the script is launched "manually" but nothing
happens at boot time.
OK, next thing(s):
   (1) is the script readable by the user (probably root) from the point
     where the ifup is? (perhaps some intervening dir isn't readable)
Tomas, you hit something here I guess : I ran the symlink as root from /etc/network/if-up.d/
:/etc/network/if-up.d# ./dynhost
And received the same e-mail as after a reboot (see below) + my dynhost address has not been updated

   (2) perhaps /home or /home/rudu isn't mounted yet when that happens?
   (3) do you see anything in your log file (you should at least see the
     first "-----", that would answer (2). In that case you might want
     do do

       "test -f /home/rudu/DynHost/ipcheck.py && echo "readable" || echo "non-readable" >> $LOGFILE
     or something similar.
I actually receive each time an e-mail confirming that my bash script has been executed plus this is logged in my logfile :
----------------------------------
mardi 16 juin 2015, 17:15:17 (UTC+0200)
Démarrage de DynHost    <-- DynHost starting
Ancienne IP: 85.68.xx.xx    <-- old IP
Nouvelle IP: 85.69.xx.xx     <-- new IP
Mise à jour!                        <-- Update!
Log ipcheck   :

What gives you the impression that it's the invocation of the python
script what is failing? How does the output to $LOGFILE look in the
failing case?
When I run my script from userland, I find something like this in my log file :
Log ipcheck   :
ipcheck.py: my.dynhost.org good 85.69.xx.xx -update successful


(BTW  I didn't go with too a fine comb through your script, but it looks
basically sensible. I wouldn't wget to a file but directly pass the result
through grep (wget -O - | grep ...), and I'd redirect the output of the
python script >> $LOGFILE, instead of passing it through $THISLOG, but
those are minor nits which shouldn't alter the result).
Thanks, I'll have a better look at this.


Reply to: