Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Jul 1999 15:54:57 nzst
From:      "Dan Langille" <dan.langille@dvl-software.com>
To:        Dan Nelson <dnelson@emsphone.com>
Cc:        questions@FreeBSD.ORG
Subject:   Re: lynx from /etc/crontab fails
Message-ID:  <37857291.187b.0@actrix.gen.nz>

next in thread | raw e-mail | index | archive | help
>In the last episode (Jul 09), Dan Langille said:
>> Dan Nelson wrote:
>> >In the last episode (Jul 09), Dan Langille said:
>> >> I'm trying to execute a shell script from a cron job.  The script
>> >> runs fine when launched manually, but when launched from a cron
>> >> job I get the following:
>> >> 
>> >> lynx: Can't access startfile http://www.yi.org/bin/dyndns.fcgi?ipaddr=

>> 
>> I haven't tried ktracing it (first I've heard of ktracing).  Here is
>> the script:
>> 
>> $ cat dns_update.sh 
>> #!/bin/sh
>> 
>> user_id="something"
>> password="secret"
>> 
>> ip_addr=`netstat -rn | egrep ^0.0.0.0 | sed -e "s,.* ,,g" | \
>>         xargs /sbin/ifconfig | grep "inet.addr" | sed -e "s,.*addr:,," \

>>         -e "s, .*,,"`
>
>Wow.  What is this thing trying to do here?  It can't possibly return a
>valid value, since "netstat -rn" prints "default" for the default route
>(not 0.0.0.0), and ifconfig never prints the string "inet addr".

I have no idea.  I've checked with two other FreeBSD users who use yi.org. 
All of us get nothing from that part of the script.  Luckly, whatever is at
the other end is clever enough to figure out what the IP address is anway.

>If you're trying to get your current dialup IP number, run this script
>from /etc/ppp/ppp.linkup, where you can pass the IP number directly
>from ppp and skip all this "guess our IP based on our default route"
>trickery.

Actually, it is much more complex than that.  The IP address is on an ADSL router.
 It has an http interface.  I query that via another script to detect a change
in IP at the router.  When that occurs, I kick off this script.

>> now=`date`
>> 
>> lynx -source -auth=$user_id:$password \
>>         http://www.yi.org/bin/dyndns.fcgi?ipaddr=$ip_addr | \
>>         sed -e "s,^,$now: ," -e "s,<.*\?>,,g"
>> 
>> 
>> So yes, some variables are set, but this shouldn't affect lynx would it?

>>
>> >Also consider using fetch, which was designed to be used in
>> >non-interactive places like cron scripts.
>> 
>> I don't know how/if fetch can be used in this instance.
>
>It looks like it could; fetch uses $HTTP_AUTH instead of a commandline
>option, but the manpage explains that well enough.  "fetch -v" will also
>print the entire error message from the remote server in case of an
>error, so it's easier to debug.

I'll try over the weekend.  Thanks for this.
--
Dan Langille


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?37857291.187b.0>