Re: Script with 'ftp' and rewrite using 'sftp'



the <<! seems to indicate the command to read the
following lines as if they were typed from the
keyboard until it reaches EOF.

Unlike the FTP command, the SFTP command does not
support password authentication when you specify a
batch command file (check
http://www.openbsd.org/cgi-bin/man.cgi?query=sftp ),
so you'll need to setup your account for
non-interactive authentication (check
http://www.astro.caltech.edu/~mbonati/WIRC/manual/DATARED/setting_up_no-password_ssh.html
).

=====================================================
-b batchfile
Batch mode reads a series of commands
from an input batchfile in-
stead of stdin. Since it lacks user
interaction it should be
used in conjunction with non-interactive
authentication. A
batchfile of `-' may be used to indicate
standard input. sftp
will abort if any of the following
commands fail: get, put,
rename, ln, rm, mkdir, chdir, ls, lchdir,
chmod, chown, chgrp,
lpwd and lmkdir. Termination on error
can be suppressed on a
command by command basis by prefixing the
command with a `-'
character (for example, -rm /tmp/blah*).
=====================================================


once set that up, just specify your private key with
the -i flag.

sftp -i <priv_key> -b batchfile
remote_user@remote_host

the equivalent commands to the ftp setup would be...

cd <remote_dir>
ls -l
put local_file.txt
ls -l
quit

also, you can specify the remote_path in the sftp
command line..

sftp -i <priv_key> -b batchfile
remuser@remhost:<rem_path>/

and remove the "cd <rem_path> " from the batch file.

but then a scp & ssh pair would do the same...

scp -i <priv_key> localfile
remUser@remhost:<rem_path>/rem_filename.txt
ssh -i <priv_key> remUser@remhost 'ls -l
<rem_path>/rem_filename.txt'


One word of caution, sftp, or scp, does not seem to do
ascii file conversions (ascii nor binary are present
on the command list for the sftp command) so the files
are transfered verbatim.

I would look into the ssh mailing list for more
specific advice.

regards,
Enrique.


--- Denny Watkins <watkins@xxxxxxxxxxxxxxx> wrote:

Aixers,

I have an old script written by someone else. The
script is as follows
NOTE: ip address,login name, password,etc have been
changed):

ftp -inv<<!
open xxx.xxx.xxx.xxx
user user-name password
cd /cgi-bin/import/
dir
as
put some.txt
dir
quit


Question #1: What does "<<!" really mean?

Question #2: How would one rewrite this script to
use sftp?

Thanks,

Denny Watkins
Morningside College
Sioux City, IA 51106-1717

Phone: 712-274-5250

Email: watkins@xxxxxxxxxxxxxxx


Enrique Sanchez Vela
email: esanchezvela@xxxxxxxxx
--------------------------------------
http://www.savetheinternet.com/



____________________________________________________________________________________
Yahoo! Music Unlimited
Access over 1 million songs.
http://music.yahoo.com/unlimited



Relevant Pages

  • Re: Scripted FTP transfer
    ... Rather then specify the username and password in your script, ... going to run the ftp script, ... If you are running this from root, the .netrc will be created in / ... I'm trying to write a FTP command file on the fly to ...
    (comp.unix.sco.misc)
  • Re: Scripted FTP transfer
    ... I'm attempting to script an FTP transfer on my UnixWare 7.1.4 server. ... I'm trying to write a FTP command file on the fly to redirect ...
    (comp.unix.sco.misc)
  • Scripted FTP transfer
    ... I'm attempting to script an FTP transfer on my UnixWare 7.1.4 server. ... I'm trying to write a FTP command file on the fly to redirect ...
    (comp.unix.sco.misc)
  • Re: .bat from asp.net w/System.Diagnostics.Process?
    ... The results of the script from the command prompt when run from an .aspx are ... The ftp call syntax that I am using allows you to have a text file with all of your ftp connection info in it. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: FTP in ASP.NET C#
    ... It has native .NET classes that will allow you to use the FTP protocol. ... >I would like to have my application FTP a file to a server after a user ... > ' This script assumes the file to be FTP'ed is in the same directory as ... > ' If there are multiple files to put, we need to use the command ...
    (microsoft.public.dotnet.languages.csharp)