Unix administration - Newbie Question - How to use SFTP & to replace FTP in shell script

This is Interesting: Free IT Magazines  
Home > Archive > Unix administration > June 2007 > Newbie Question - How to use SFTP & to replace FTP in shell script





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Newbie Question - How to use SFTP & to replace FTP in shell script
underh20.scubadiving@gmail.com

2007-06-05, 7:26 pm

Hello,

Our server is running Solaris 10.

We are looking for help in porting the following working
"function" in our shell script from FTP to SFTP. So far, we are
getting errors when rewriting the code to use SFTP. Any advice on
how to revise the code will be most appreciated. Thanks, Bill


Here's an example of a function that is used to ftp files ...

function ftp_file {
set -x
ftp -nvi <<- !END!
open $ftp_host $ftp_port
user $ftp_id $ftp_pw
ascii
prompt
put $file
quit
!END!
}

ThomasRStevenson@gmail.com

2007-06-15, 7:27 pm


I know you indicated that you want to use sftp, but the script might
be easier to write if you use scp (assuming it is available to use).
See man pages on scp for more details.

If you really want to use scp, you might want to take a look at
expect, and in particular the autoexpect command. expect is based on
tcl, and you can find good books on both subjects. A google search on
autoexpect will also locate a great deal of info on the subject.

On Jun 5, 6:07 pm, underh20.scubadiv...@gmail.com wrote:
> Hello,
>
> Our server is running Solaris 10.
>
> We are looking for help in porting the following working
> "function" in our shell script from FTP to SFTP. So far, we are
> getting errors when rewriting the code to use SFTP. Any advice on
> how to revise the code will be most appreciated. Thanks, Bill
>
> Here's an example of a function that is used to ftp files ...
>
> function ftp_file {
> set -x
> ftp -nvi <<- !END!
> open $ftp_host $ftp_port
> user $ftp_id $ftp_pw
> ascii
> prompt
> put $file
> quit
> !END!
>
> }



Michael Heiming

2007-06-16, 7:17 pm

In comp.unix.admin ThomasRStevenson@gmail.com <ThomasRStevenson@gmail.com>:
> On Jun 5, 6:07 pm, underh20.scubadiv...@gmail.com wrote:
[vbcol=seagreen]
[vbcol=seagreen]
[vbcol=seagreen]
[vbcol=seagreen]
[vbcol=seagreen]
[vbcol=seagreen]
> I know you indicated that you want to use sftp, but the script might
> be easier to write if you use scp (assuming it is available to use).
> See man pages on scp for more details.


> If you really want to use scp, you might want to take a look at
> expect, and in particular the autoexpect command. expect is based on
> tcl, and you can find good books on both subjects. A google search on
> autoexpect will also locate a great deal of info on the subject.


Please don't, enable key login for the user in question. Extra
points for using ssh agent.

sftp -b - $ftp_host << EOF
put $file
EOF

Should do the trick once keylogin is working.

--
Michael Heiming (X-PGP-Sig > GPG-Key ID: EDD27B94)
mail: echo zvpunry@urvzvat.qr | PERL -pe 'y/a-z/n-za-m/'
#bofh excuse 318: Your EMAIL is now being delivered by the USPS.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com