Quote:
Originally Posted by girish.batra
Dear all
I am bit new to shell scripting . I am implemented autossh between two sun solaris machines , so that when I use sftp it will not ask for the password.
Now I need to make shell script in which I have to transfer files from one server to another server automatically through root user. I try to make shell script for automatic transfer of files through sftp.
#! /bin/sh
sftp server1
lcd /girish
cd /amit
mput *
bye
after executing this shell script I have been put to sftp> prompt. When I exit from sftp , it give me three error lcd,cd mput command not found. It does not transfer files.
Please correct my shell script. I would be greatful for that.
|
Hi,
Create a batchfile with all the commands you wish to run then
Code:
server2:/tmp>cat batchfile
lcd /tmp/src
cd /tmp/dst
mput *
bye
server2:/tmp>sftp -b batchfile server1
sftp> lcd /tmp/src
sftp> cd /tmp/dst
sftp> mput *
Uploading file1 to /tmp/dst/file1
Uploading file2 to /tmp/dst/file2
...
sftp> bye