replacing ftp with sftp in the script....


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting replacing ftp with sftp in the script....
# 1  
Old 10-24-2011
CPU & Memory replacing ftp with sftp in the script....

Hi,

I have the following bash script(related to ftp) that read the parameters from the properties file and then transfer some files to the remote machine...

following is the bash script ....
Code:
#!/bin/sh

. ftp.properties

ftp -vin >> ftp.log <<-!
        open $RemoteIp
        user $userid $password
        cd $DestFolder
        lcd $SrcFolders
        put $SourcefilePattern
        bye
        !

Now in the above scripT, I am using ftp what if I cahange the ftp in the Sftp...what effect would it bring...please guide me on that..!!Smilie

Last edited by Franklin52; 10-24-2011 at 03:53 AM.. Reason: Please use code tags, thank you
# 2  
Old 10-24-2011
I think you cannot supply password in batch (non-interactive) mode in SFTP (unless you are using automation tools like expect see (How To Expect | Linux Magazine). I would think you would be much better off using key based password-less authentication (see Password-less logins with OpenSSH).
# 3  
Old 10-24-2011
Check below script to see whether it satisfies yor reuqrement.
Code:
#!/bin/sh
. ftp.properties

sftp -vin >> ftp.log <<EOF
open $RemoteIp
user $userid $password
cd $DestFolder
lcd $SrcFolders
put $SourcefilePattern
bye
EOF


Last edited by Franklin52; 10-24-2011 at 03:53 AM.. Reason: Please use code tags, thank you
# 4  
Old 10-24-2011
sftp over ftp..!!

Hi smilesavvy,
as shown by you have added the sftp in place of ftp...as shown below...
Code:
#!/bin/sh
 . ftp.properties
  sftp -vin >> ftp.log <<EOF 
open $RemoteIp
 user $userid
 $password
 cd $DestFolder
 lcd $SrcFolders
 put $SourcefilePattern
 bye
 EOF

could you please explain what additional advantages does sftp gives over ftp...?Smilie
# 5  
Old 10-24-2011
I would suggest you to check the MAN page.

sftp is an interactive file transfer program, similar to ftp, which performs all operations over an encrypted ssh transport. It may also use many features of ssh, such as public key authentication and compression. sftp connects and logs into the specified host, then enters an interactive command mode.

The second usage format will retrieve files automatically if a non-interactive authentication method is used; otherwise it will do so after successful interactive authentication.

The third usage format allows sftp to start in a remote directory.

The final usage format allows for automated sessions using the -b option. In such cases, it is necessary to configure non-interactive authentication to obviate the need to enter a password at connection time
This User Gave Thanks to smilesavvy For This Post:
# 6  
Old 10-24-2011
Quote:
Originally Posted by smilesavvy
I would suggest you to check the MAN page.

sftp is an interactive file transfer program, similar to ftp, which performs all operations over an encrypted ssh transport. It may also use many features of ssh, such as public key authentication and compression. sftp connects and logs into the specified host, then enters an interactive command mode.

The second usage format will retrieve files automatically if a non-interactive authentication method is used; otherwise it will do so after successful interactive authentication.

The third usage format allows sftp to start in a remote directory.

The final usage format allows for automated sessions using the -b option. In such cases, it is necessary to configure non-interactive authentication to obviate the need to enter a password at connection time

Hi smilesavvy,

Thanks a lot for the valuable information, I will now replace the ftp and use sftp in my script.,,thanks a lot again..!!Smilie
# 7  
Old 10-24-2011
Is there a reason why you are not using scp? (can be configured to not ask for passwd...)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sftp equivalent to ftp -n

Hi all. I can put ftp command in shell script together with the password using ftp -n 10.1.2.34 << EOF user userid password cd /test_dir/ prompt bin get filename.txt EOF But the -n option is not available for sftp. What alternatives do I have then to bypass the password prompt? ... (6 Replies)
Discussion started by: aimy
6 Replies

2. Shell Programming and Scripting

FTP and SFTP functionality

Hi Friends, I need to make a Unix script, where i need ftp and sftp functionality. Let me describe in details: I need to import few files from remote server, now these remote server either support ftp or sftp not both. So i need a script where my script will try to do ftp first and if it... (8 Replies)
Discussion started by: gnnsprapa
8 Replies

3. Shell Programming and Scripting

Migration from FTP to SFTP

Hi Everyone, We are migrating from FTP to SFTP. We used the following script for FTP: echo "ftp -np -i -v << EOF" >> ${FTP_READY_FILE} echo "open ${SRC_FTP_SERVER} " >> ${FTP_READY_FILE} echo "user ${SRC_FTP_USER} ${SRC_FTP_PWD}" >> ${FTP_READY_FILE} echo "binary" >> ${FTP_READY_FILE}... (5 Replies)
Discussion started by: Jigsaw16
5 Replies

4. UNIX for Dummies Questions & Answers

Replace FTP with SFTP

Hi All, I am in the process of replacing SFTP instead of FTP to make data more secure. In one of my FTP script I have Quote Site command. I would like to know, what is the option to replace this in SFTP ftp -n -v <<! | tee -a $LOG | grep "Transfer complete" >/dev/null open... (3 Replies)
Discussion started by: desai.vishnu
3 Replies

5. Shell Programming and Scripting

Migrate from FTP to SFTP

Hi,I am using following code for FTP in shell script file and it is working.Now I want to migrate from FTP to SFTP.What code changes/steps I have to perform for SFTP ? ftp -in <<FIN open $SAP_UP_SERVER user $SAP_UP_USER $SAP_UP_PASSWORD asc put... (7 Replies)
Discussion started by: Nitin Varshneya
7 Replies

6. Shell Programming and Scripting

lftp script to connect to external sftp site and download to internal ftp and then send email

Hi there, I'm new to shell scripting and need some help if possible? I need to create a shell script (.sh) to run as a cron job on an ubuntu linux server to connect to an external sftp sites directory using credentials (which I have) and then download to our internal ftp server and then copy... (3 Replies)
Discussion started by: ghath
3 Replies

7. Shell Programming and Scripting

SFTP-how to log individual sftp command error while executing shell script

Hi, I have situation where i need to automate transferring 10000+ files using sftp. while read line do if ; then echo "-mput /home/student/Desktop/folder/$line/* /cygdrive/e/folder/$line/">>sftpCommand.txt fi done< files.txt sftp -b sftpCommand.txt stu@192.168.2.1 The above... (1 Reply)
Discussion started by: noobrobot
1 Replies

8. Shell Programming and Scripting

script from ftp to sftp

salmo allikm warhmat allah wabrakato i have my own server and upload file with ftp with this script ftp -n xxxxxxxxxcom<<EOF user xxxx xxxx binary put image bye EOF i want to convert to sftp or secure protocol when change to sftp no respond it stop i don't know how to start ... (7 Replies)
Discussion started by: pua06
7 Replies

9. AIX

AIX ftp/sftp script monitor to failed logins

Hi All, Any idea on how to write a script on AIX 5.3 to monitor ftp or sftp login failed. Thanks and more power, Itik (2 Replies)
Discussion started by: itik
2 Replies

10. Shell Programming and Scripting

'Upgrading' to sftp from ftp

Somebody made a policy that 'we use sftp now instead of ftp'. I have recommended we use scp because I can't for the life of me think of a *good* reason to use sftp and not scp. But most of what I do is stupid stuff without a good reason. I get judged on how much I can just say yes, no matter how... (1 Reply)
Discussion started by: CodeMonkey76
1 Replies
Login or Register to Ask a Question