Unix administration - FTP question

This is Interesting: Free IT Magazines  
Home > Archive > Unix administration > January 2004 > FTP question





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 FTP question
Pete Rau

2004-01-23, 5:11 pm

Is there a way to invoke FTP and pass parms to ftp through a file.
Something like FTP <input.


S. Anthony Sequeira

2004-01-23, 5:11 pm

On Fri, 09 Jan 2004 12:01:37 -0700, Pete Rau penned:
quote:

> Is there a way to invoke FTP and pass parms to ftp through a file.
> Something like FTP <input.



If you are able to install software, have a look at ncftp.

Alternatively, expect, may be able to help you, though I may well be
wrong.

--
Tony

phn@icke-reklam.ipsec.nu

2004-01-23, 5:11 pm

Pete Rau <Pete_Rau@beamspeed.net> wrote:
quote:

> Is there a way to invoke FTP and pass parms to ftp through a file.
> Something like FTP <input.



yes :
( depending on version used of course )
From memory ( check your manpages )

ftp -n <host> <<EOF
user <username>
pass <password>
get file
put file
EOF


If you need "filenames as parameters adjust slightly :

echo "ftp -n <host> <<EOF" > tempfile
echo "user <username>" >> tempfile
echo "pass <password>" >> tempfile
echo "get $1" >> tempfile
echo "EOF" >> tempfile

# now execute the above
sh tempfile
# and clean up
rm tempfile




--
Peter Håkanson
IPSec Sverige ( At Gothenburg Riverside )
Sorry about my e-mail address, but i'm trying to keep spam out,
remove "icke-reklam" if you feel for mailing me. Thanx.
Danny

2004-01-23, 5:11 pm

Pete Rau wrote:
quote:

> Is there a way to invoke FTP and pass parms to ftp through a file.
> Something like FTP <input.
>
>



Alternatively, check `man ftp` to see that you have a version that
supports .netrc. If so, you can create $HOME/.netrc with a macdef init
entry that runs all your commands, like so:

--------------------------------------------------------------
machine sunsite.unc.edu login ftp password myname@ macdef init
cd pub/linux
bin
hash
get 00-find.Linux.gz
quit

--------------------------------------------------------------

Then, chmod 600 $HOME/.netrc

Don't forget the empty line which ends the init macro.

Then, just run `ftp sunsite.unc.edu` and watch the magic happen.
--
Danny C.

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com