The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 02-20-2008
andryk's Avatar
andryk andryk is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2003
Posts: 448
Quote:
Originally Posted by girish.batra View Post
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

a simple scp could have done the trick, its all up to ya