Le 16/06/2015 12:47, to...@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 :
I wrote a bash script to compare my actual IP address to the one of
my DynDNS service provider.
That bash script calls a python script (provided by the DynDNS
service) to update my DynDNS Address if necessary.
Everything runs smoothly when I run my script by hand as root or as
a standard user.
But when I put a symbolic link to my script in /etc/network/if-up.d/
in order to make the checking / updating automatic at boot time, the
python script doesn't seem to be launched at all, although my Bash
script logs fine and sends me a success e-mail.
What could prevent a python script to be executed in such circumstances ?
Difficult to say without seeing the actual scripts, but my hunch would be
that some environment variable(s) is different when run "by hand" and
when run from if-up. The first candidate would be, of course, PATH.
If you call ipcheck from the shell script just like "ipcheck.py", then
the shell looks for it in all places indicated by $PATH.
As a first test, try putting the call with the full path like so:
/usr/local/bin/ipcheck.py (replace the path by the correct one in
your case).
hth
- -- tomás
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.
TIA
Rudu
-------------------------------------------------------------------------
#! /bin/sh
LOGFILE="/home/rudu/DynHost/dynhost.log"
HOST=my.dynhost.org
LOGIN=mylogin
PASSWORD=mypassword
OPTIONS="-r checkip.dyndns.org:8245"
THISLOG="/tmp/thislog.txt"
getip() {
wget -O /home/rudu/DynHost/index.html -o /dev/null
http://checkip.dyndns.org/
IP=`cat /home/rudu/DynHost/index.html | fgrep "Address" | cut
-f2 -d":" | cut -f1 -d"<" | sed -e "s/ //g"`
OLDIP=`dig my.dynhost.org | grep -i -A 1 'answer
section' | grep my.dynhost | cut -f2 -d"A" | cut -f2 | sed -e "s/ //g"`
}
#
echo ---------------------------------- >> $LOGFILE
echo `date` >> $LOGFILE
echo Démarrage de DynHost >> $LOGFILE
getip
if [ "$IP" ]; then
if [ "$OLDIP" != "$IP" ]; then
echo -n "Ancienne IP: " >> $LOGFILE
echo $OLDIP >> $LOGFILE
echo -n "Nouvelle IP: " >> $LOGFILE
echo $IP >> $LOGFILE
echo "Mise à jour!" >> $LOGFILE
echo "Log ipcheck : " > $THISLOG
/usr/bin/python /home/rudu/DynHost/ipcheck.py $OPTIONS
$LOGIN $PASSWORD $HOST >> $THISLOG
cat $THISLOG >> $LOGFILE
SUBJECT="Update DynDNS OVH"
# Email To ?
EMAIL="myem...@mydomain.com"
# send an email using /bin/mail
/usr/bin/mail -s "$SUBJECT" "$EMAIL" < $THISLOG
else
echo IP Identique! Pas de mise à jour. >> $LOGFILE
fi
else
echo Panique à bord: Aucune IP Disponible!! >> $LOGFILE
fi
--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: https://lists.debian.org/55801e2a.3000...@cegetel.net