Re: Non-Interactive SFTP

From: Shekhar Dhotre (Shekhar.Dhotre@LENDLEASEREI.COM)
Date: Fri Apr 25 2003 - 22:46:11 EDT


Yes , I have automated sftp using expect ..see below

Poking around /usr/local/bin with the command ll | more, I found
autoexpect. It's not in the book, What`s Autoexpect ?
autoexpect - generate an EXPECT script from watching a session.
This is a cool program. I can run a TELNET or FTP session to a Linux from
AIX or between any systems and create an EXPECT script from the session
that I can run any time I wish.

( Ftp`d one file from hrdev to linux server and created test1.exp script
using autoexpect )

f3n43#autoexpect -f test1.exp sftp egbert
autoexpect started, file is test1.exp
Connecting to egbert...
root@egbert's password:
sftp> put README
Uploading README to /root/README
sftp> quit
autoexpect done, file is test1.exp

The file test1.exp is the script created by autoexpect.Examining test1.exp
shows the details of the two-way conversation between the Linux machine
and the AIX. Every character is saved in either a send or expect command.
Even the password is saved, so care must be taken with these scripts.

 I can rerun this script(test1.exp) any time I wish simply by typing
test1.exp at the prompt. It puts README file by reading commands in the
script .

f3n43 /usr/sshdownload/expect/expect-5.38>test1.exp
spawn sftp egbert
Connecting to egbert...
root@egbert's password:
sftp> put README
Uploading README to /root/README
sftp> quit
f3n43 /usr/sshdownload/expect/expect-5.38>

"Naylor, Jim" <Jnaylor@SCHNUCKS.COM>
Sent by: IBM AIX Discussion List <aix-l@Princeton.EDU>
04/25/2003 03:25 PM
Please respond to
IBM AIX Discussion List <aix-l@Princeton.EDU>

To
aix-l@Princeton.EDU
cc

Subject
Re: Non-Interactive SFTP

I tried this command according to the man pages:

scp -B username@servername:test.file

and it kept comming back with the usage. What am I doing wrong?

-----Original Message-----
From: Aaron Morris [mailto:aaronmorris@MINDSPRING.COM]
Sent: Friday, April 25, 2003 12:41 PM
To: aix-l@princeton.edu
Subject: Re: Non-Interactive SFTP

Why not just use scp?

Naylor, Jim wrote:
> Hello All,
> According to the man pages on SFTP you can use the -b to automate SFTP.
The
> -b points to a command file that has the sftp commands. Has anyone been
> able to get SFTP to work in a script form like ftp. We do the following
for
> ftp automation:
>
> echo "user username password" > ftpfile
> echo "cd abcd" >> ftpfile
> echo "get filename" >> ftpfile
> echo "bye" >> ftpfile
>
> ftp ftpsite < ftpfile
>
> I have tried to do something similar with SFTP but cannot seem to get it
to
> work. This script needs to be run by a user other than the sftp login
user.
> According to the man pages I would have to do sftp username@sftpserver.
Any
> ideas would be appreciated.
>
> Thanks,
> Jim Naylor
> Unix Systems Administrator
> Schnuck Markets, Inc.
> * Direct: (314) 994-4784
> *)) Cell: (314) 691-0186
> * Fax : (314) 994-4684
> * jnaylor@schnucks.com
>

--
Aaron W Morris
decep
PGP Key ID:  259978D1


This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:16:46 EDT