eric@lucii.org on 7 Mar 2004 12:58:02 -0000


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

Re: [PLUG] Script FTP session?


On Sun, Mar 07, 2004 at 01:03:20AM -0500, Martin DiViaio wrote:
> 
> [...]
> 
> On the 7th day of March in the year 2004 you wrote:
> 
> > Date: Sun, 7 Mar 2004 00:41:31 -0500
> > From: kaze <kaze@voicenet.com>
> > To: PLUG Listserv <plug@lists.phillylinux.org>
> > X-Spam-Status: No, hits=-4.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_SORBS 
> > 	autolearn=no version=2.63
> > Subject: [PLUG] Script FTP session?
> > 
> > Sorry if this one is to easy, but can I control a (non-GUI / CLI) FTP
> > session from a shell script? Like send username, password, cd, put, get, and
> > then bye? Going farther how might I insert from the script timed pauses
> > between commands, like to wait five minute between the put and then next
> > command.
> > 
> 
> Look at the expect(1) and autoexpect(1) man pages.

Agreed.  Here is a script that I use from the command line to 
send a file to a friend's webdav server.  The same applies to ftp
sessions.  I just type:  "putdave filename"
and the file is sent over.  There is zero error checking in this script
because it does not need it... I watch the results.

Eric


> #!/usr/bin/expect --
> 
> exp_version -exit 5.0
> 
> if ($argc!=1) {
>    send_user "ERROR:  missing argument(s)\n"
>    send_user "\n    Usage:  todave <filename> \n"
>    exit
> } else {
>    set file $argv
> }
> 
> set login username
> set password PaSSwORd
> 
> set timeout 60
> spawn /usr/local/bin/cadaver https://friends.ip.com:8088
> expect "Username*:"
> send "$login\r"
> expect "Password:"
> send "$password\r"
> expect "dav:/>"
> send "mput $file\r"
> expect "dav:/>"
> send "bye\r"
> close
> wait
>  

-- 
#  Eric Lucas
#     "Oh, I have slipped the surly bond of earth
#      And danced the skies on laughter-silvered wings...
#                             -- John Gillespie Magee Jr.
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug