FTP to SFTP in shell scripting
Posted
by Kimi
on Stack Overflow
See other posts from Stack Overflow
or by Kimi
Published on 2010-05-12T10:37:40Z
Indexed on
2010/05/15
12:24 UTC
Read the original article
Hit count: 328
This script is to connect to different servers and copy a file from a loaction defined. It is mandatory to use sftp and not ftp.
#!/usr/bin/ksh -xvf
Detail="jyotibo|snv4915|/tlmusr1/tlm/rt/jyotibo/JyotiBo/ jyotibo|snv4915|/tlmusr1/tlm/rt/jyotibo/JyotiBo/"
password=Unix11!
c_filename=import.log
localpath1=`pwd`
for i in $Detail
do
echo $i
UserName=`echo $i | cut -d'|' -f1`
echo $UserName
remotehost=`echo $i | cut -d'|' -f2`
echo $remotehost
remote_path=`echo $i | cut -d'|' -f3`
echo $remote_path
{
echo "open $remotehost
user $UserName $password
lcd $localpath1
cd $remote_path
bi
prompt
mget $c_filename
prompt
"
} |ftp -i -n -v 2>&1
done
I want to do the similar thing using sftp instead of ftp.
© Stack Overflow or respective owner