I don't know how to do it with plain bash, but
I make a page called ipaddress.html and then
send it to ihug with an expect script running lftp.

It has no error checking or anything like that.
I use a bash wrapper script to find the local
ip address, (such as from /sbin/ifconfig) and put in
in a file (I make an html file), and run the
expect script to send it over ftp.
It isn't failsafe, but it works ok.


#!/usr/bin/expect
send "Attempting to update ip address on ihug ...\r"
spawn lftp [EMAIL PROTECTED]/public_html
set timeout 30
expect assword {send hardcodedpassword\r}
send "put /local/path/to/ipaddress.html\r"
expect ransferred {send "quit\r"}


Patrick Lesslie


On 13 Dec 2002, Karl Bowden wrote:

> What is the easiest way to upload a file from a bash script to a ftp
> server?
>
> I have a script on a remote box that checks every so often from cron
> what the ip address is and if it changes then uploads the change to my
> ftp server, because the remote box is on a telstra cable connection and
> the owner of the box still finds it difficult to find the ip address
> when ever something goes wrong, and I have to ssh in. The script will
> have the username and password hardcoded.
>
> ps.. I also want to make sure that I will always have a back door....
> he he he
>
> Regards,
> Karl Bowden
>


-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to