Results 1 to 9 of 9
my problem:
i made an script to publish my current server ip (my provider uses dynamic ips) on a website. the script works fine starting it manually, but don't as ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 05-27-2004 #1Just Joined!
- Join Date
- May 2004
- Posts
- 5
script problem - acts different :?
my problem:
i made an script to publish my current server ip (my provider uses dynamic ips) on a website. the script works fine starting it manually, but don't as a cronjob.
destribution: debian (knoppix 3.4)
script:
result (started manually):#! /bin/bash
# ftp-script
rm -f /data/currentip.html
echo "<html><body><font face='Tahoma' color='green' style='font-size: 10pt'><u>Derzeitige Server IP:</u>
<font color='black' style='font-size: 8pt'>" >> /data/currentip.html
/sbin/ifconfig ppp0 > /data/ip
/bin/cat /data/ip | /bin/grep inet | /bin/sed 's/.*Adresse:\([0-9\.]*\) .*/\1/g' >> /data/currentip.html
echo "
PuTTY Client</body></html>" >> /data/currentip.html
cp /data/currentip.html /var/www/currentip.html
result (started as a cronjob):Derzeitige Server IP:
217.225.115.133
PuTTY Client
any ideas?Derzeitige Server IP:
inet addr:217.225.115.133 P-t-P:217.5.98.61 Mask:255.255.255.255
PuTTY Client
jens
- 05-27-2004 #2Linux Engineer
- Join Date
- Apr 2003
- Location
- Sweden
- Posts
- 796
Thats a litte wierd, it seems like your regexp doest get applied when you execute it from cron.
Try to change this line
Witch this:Code:/bin/cat /data/ip | /bin/grep inet | /bin/sed 's/.*Adresse:\([0-9\.]*\) .*/\1/g' >> /data/currentip.html
Which is a little simplier....and see whats happend. Also check to output file for ifconfig from cron and from a manual run to see if the differs.Code:/bin/cat /data/ip | grep "inet addr" | grep Bcast | cut -d ":" -f2 | cut -d " " -f1
Regards
Andutt
- 05-27-2004 #3Just Joined!
- Join Date
- May 2004
- Posts
- 5
that's my ifconfig ppp0 output (manually+cronjob):
it's german, so your command line can't work that way. i replaced inet addr with "inet Adresse" and Bcast with "Maske".ppp0
Protokoll:Punkt-zu-Punkt Verbindung
inet Adresse:217.225.115.133 P-z-P:217.5.98.61 Maske:255.255.255.255
UP PUNKTZUPUNKT RUNNING NOARP MULTICAST MTU:1492 Metric:1
RX packets:349881 errors:0 dropped:0 overruns:0 frame:0
TX packets:394153 errors:0 dropped:0 overruns:0 carrier:0
Kollisionen:0 Sendewarteschlangenlänge:3
RX bytes:215823975 (205.8 MiB) TX bytes:278545283 (265.6 MiB)
result manually: just perfect
result cronjob: no ip output in currentip.html
thanks anyway
- 05-27-2004 #4Linux Engineer
- Join Date
- Apr 2003
- Location
- Sweden
- Posts
- 796
Ok
Try this then....its should work
Code:/bin/cat /data/ip | grep "inet Adress" | grep Maske | cut -d ":" -f2 | cut -d " " -f1
Try to execute it by hand and by cron to see if it results the same....or if it workes better...Regards
Andutt
- 05-27-2004 #5Just Joined!
- Join Date
- May 2004
- Posts
- 5
hmm, replace "inet Adresse" with "inet Adress"? I don't notice any other change. Result is the same like in my third post
.
- 05-27-2004 #6Linux Engineer
- Join Date
- Apr 2003
- Location
- Sweden
- Posts
- 796
But if you run my command on the /data/ip file that looksl like this
You should get :217.225.115.133Code:ppp0 Protokoll:Punkt-zu-Punkt Verbindung inet Adresse:217.225.115.133 P-z-P:217.5.98.61 Maske:255.255.255.255 UP PUNKTZUPUNKT RUNNING NOARP MULTICAST MTU:1492 Metric:1 RX packets:349881 errors:0 dropped:0 overruns:0 frame:0 TX packets:394153 errors:0 dropped:0 overruns:0 carrier:0 Kollisionen:0 Sendewarteschlangenlänge:3 RX bytes:215823975 (205.8 MiB) TX bytes:278545283 (265.6 MiB)
I thought that was your issue??Regards
Andutt
- 05-27-2004 #7Just Joined!
- Join Date
- May 2004
- Posts
- 5
äh yes, but your 2nd post was nearly the same like my 2nd (i changed your command line from your first post for german output before), so i was confused
.
however, i should get 217.225.115.133. and i do! but only manually.
the cronjob don't get any ip. very strange
- 05-27-2004 #8Just Joined!
- Join Date
- May 2004
- Location
- San Antonio, TX
- Posts
- 49
Possibly stating the obvious, but what user are you when you run this manually? Crontab (at least the versions I've played with) runs as a default low-level user if you don't include a sudo or the like, and so perhaps that low-level user in your dist doesn't have permissions to check this?
Originally Posted by fraxx
HTH,
Ewan
- 05-27-2004 #9Just Joined!
- Join Date
- May 2004
- Posts
- 5
hmmm good idea!


Reply With Quote
