How to use ftp and sftp in linux
Even though ftp is not good for security when you use it in the scripts, it is still easily usable and powerful. I use ftp and sftp scripts for batch job.
ftp script
#!/bin/bash
. ~yourid/.bash_profile > /dev/null
ipaddr=
userid=
password=
remotedir=
remotefiles=
ftp -i -n <<!
open $ipaddr
user $userid $password
ascii
cd $remotedir
mget $remotefiles
bye
!
sftp script
#!/bin/ksh
ipaddr=
userid=
password=
remotefiles=
expect << EOS
set timeout 120
spawn sftp $userid@$ipaddr:
expect "password: "
send "$password\n"
expect "sftp>"
send "dir $remotefiles\n"
expect "sftp>"
send "bye\n"
EOS
Leave a comment