Hi All,
I'm in need of script which picks multiple files from one server and do sftp to multiple servers. Any help would be much appreciated.
Hi All,
I'm in need of script which picks multiple files from one server and do sftp to multiple servers. Any help would be much appreciated.
This is a simple example example of putting a file with sftp, You can create a similar script to get file(s):
#!/usr/bin/ksh
# test_sftp.sh
sftp -b /dev/stdin -v -o BatchMode=yes -o IdentityFile=/export/home/user/.ssh/id_rsa -o Port=22 user@host <<ENDSFTP
cd /home/user/test
put /export/home/user/test/test.txt test.txt.xferring
rename test.txt.xferring test.txt
quit
ENDSFTP
rc=$?
if [[ $rc != 0 ]] then
print "Error occured...$rc" `date "+%Y-%m-%d-%H.%M.%S"`
else
print "Successful transfer...$rc" `date "+%Y-%m-%d-%H.%M.%S"`
fi
raghunsi,
This is an outstanding example that uploads a file to a specific host. Do you know how to tweak it in order to do the same thing for multiple servers? (For example, with a while
loop). Let us know if you need further help and we'll be more than glad to lend a hand.