1834089 Members
2268 Online
110063 Solutions
New Discussion

Re: sftp

 
p7
Frequent Advisor

sftp

hi all

a client was using regular ftp and now is moving to sftp. the only problem was he was using it in cron with something like:

set -o xtrace
/tmp/tmp2
tmpfile=tmp_error_log
USR='user'
PASSWD='user'
date "+******************* Today is %A, %B %d, %Y ********************"
cd /tmp/tmp2
ftp -nv << EOF1
open 10.1.2.3
user test Ylh3\&fk\#
get TESTO1.TXT
delete TEST01.TXT
quit
EOF1

is there an equivilent in sftp?

thx in advance
2 REPLIES 2
Steven E. Protter
Exalted Contributor

Re: sftp

ftp -nv << EOF1

change to

sftp << EOF1



Test the commands, but most of the ftp commands work with sftp.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Michael Selvesteen_2
Trusted Contributor

Re: sftp

Try the following

1. Set up SSH public key authentication for the user between local host and remote host.

2. Copy the file transfer commands to a batch file

3. Sample file may look like

-get Test01.txt
-delete Test01.txt
quit

"-" is nescessary to enforce sftp not to abort and to continue executing succesive commands when a command fails

4.Place the batch file to a secure location.

5. Replace the ftp command as

sftp -b /path/to/batchfile user@remotehost.


All the Best