|
Home > Archive > Unix Shell > November 2006 > shell script to FTP a file?
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 |
shell script to FTP a file?
|
|
| laredotornado@zipmail.com 2006-11-14, 1:16 pm |
| Hi,
I am running Fedora Core 5 Linux and I am looking for a shell script to
upload a file to a remote FTP server. I know the host, username,
password and starting directory. Can someone provide me with a series
of commands or guidance to write a shell script to FTP the file?
Thanks, - Dave
| |
| Chris F.A. Johnson 2006-11-14, 7:24 pm |
| On 2006-11-14, laredotornado@zipmail.com wrote:
> Hi,
>
> I am running Fedora Core 5 Linux and I am looking for a shell script to
> upload a file to a remote FTP server. I know the host, username,
> password and starting directory. Can someone provide me with a series
> of commands or guidance to write a shell script to FTP the file?
Put the username and password in your .netrc file (man ftp or man
netrc for more info).
printf "%s\n" "cd REMOTE.DIRECTORY" "put FILENAME" | ftp HOST.NAME
Replace the words in caps with the appropriate values.
--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
| |
|
| laredotornado@zipmail.com wrote:
> I am looking for a shell script to upload a file to
> a remote FTP server.
Why write your own when you can steal^H^H^H^H^Huse
someone else's debugged code? I find "niftp" by Michael
Wang to be quite workable.
http://web.unixlabplus.com:8080/unix-prog/niftp/niftp
Addenda: I have recently found and investigated a "new
age" version of the usual network copy script or app
(like mirror, rsync, scopy, netcat and the many
others) that uses many different methods -- including
_builtin_ network transfer facilities in ksh and newer
bash: "hurl" (Http URL) for bash3, ksh88 and ksh93.
It is quite impressive, although a failing is that it does
not yet implement FTP transfer. It is available in the
free AT&T AST library "INIT" package, in path
src/cmd/INIT/hurl.sh. All scripts and ports are available
through the kornshell.com portal. The manpage can be
read at:
http://public.research.att.com/~gsf/man/man1/hurl.html.
=Brian
| |
| manish 2006-11-15, 1:30 am |
|
laredotornado@zipmail.com wrote:
> Hi,
>
> I am running Fedora Core 5 Linux and I am looking for a shell script to
> upload a file to a remote FTP server. I know the host, username,
> password and starting directory. Can someone provide me with a series
> of commands or guidance to write a shell script to FTP the file?
>
> Thanks, - Dave
Hi
One solution is the " -s:filename " option with the ftp command . In
the filename
you could have the username and password entered followed by the put or
get statement .
Regards,
Manish.
| |
| laredotornado@zipmail.com 2006-11-15, 1:20 pm |
| My FTP program doesn't seem to support "-s"
ftp: s: unknown option
Usage: ftp [-v] [-d] [-i] [-n] [-g] [-k realm] [-f] [-x] [-u] [-t]
[host]
Is there another client FTP program I should be using? - Dave
manish wrote:
> laredotornado@zipmail.com wrote:
>
> Hi
>
> One solution is the " -s:filename " option with the ftp command . In
> the filename
> you could have the username and password entered followed by the put or
> get statement .
>
> Regards,
> Manish.
| |
| PDreyer 2006-11-16, 7:29 am |
|
On Nov 15, 5:10 pm, laredotorn...@zipmail.com wrote:[vbcol=seagreen]
> My FTP program doesn't seem to support "-s"
>
> ftp: s: unknown option
> Usage: ftp [-v] [-d] [-i] [-n] [-g] [-k realm] [-f] [-x] [-u] [-t]
> [host]
>
> Is there another client FTP program I should be using? - Dave
>
>
>
> manish wrote:
>
>
>
>
>
e.g.
ftp -nv zok <<EOF
user anonymous guest@unknown
cd $mydir
bi
put $myfile
quit
EOF
| |
| Why Tea 2006-11-16, 7:29 am |
|
laredotornado@zipmail.com wrote:
> My FTP program doesn't seem to support "-s"
>
> ftp: s: unknown option
> Usage: ftp [-v] [-d] [-i] [-n] [-g] [-k realm] [-f] [-x] [-u] [-t]
> [host]
>
> Is there another client FTP program I should be using? - Dave
That "-s:" option seems to be supported in Windows ftp clients. In the
Unix world, you can automate this type of task with "expect" easily
(this answer has been mentioned many times by others). Check out
http://expect.nist.gov for examples.
/Why Tea
|
|
|
|
|