This is how we can automate a ftp session in BASH without taking the help of expect.
As ftp provides "quote" option to send username and password, we can use that to send the same.
# FTP function to get a file from REMOTE host
f_GET_FTP(){
local HOST=$1
local USER=$2
local PASSWD=$3
ftp -n $HOST > $TEMPDIR/ftpsh.worked.$$ 2> $TEMPDIR/ftpsh.failed.$$ << EOF
quote USER $USER
quote PASS $PASSWD
cd $DESTDIR
bin
get $4
quit
EOF }
#Calling the function
f_GET_FTP 172.23.0.12 user5 passuser5 input.out
1 comment:
Hi Jadu,
How about scp?
#scp user@172.16.3.14:$remote_dir/* $local_dir
How to entry password when prompted?
Thank's
Post a Comment