Re: Script with 'ftp' and rewrite using 'sftp'
- From: Enrique Sanchez Vela <esanchezvela@xxxxxxxxx>
- Date: Fri, 2 Feb 2007 17:52:34 -0800
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
- References:
- Script with 'ftp' and rewrite using 'sftp'
- From: Denny Watkins
- Script with 'ftp' and rewrite using 'sftp'
- Prev by Date: Re: error SRC 11007631 Power/Cooling
- Next by Date: CN=Gary L Heilman/O=Dairynet is out of the office.
- Previous by thread: Script with 'ftp' and rewrite using 'sftp'
- Next by thread: Re: Script with 'ftp' and rewrite using 'sftp'
- Index(es):
Relevant Pages
|