On 17-Dec-98 WIll wrote:
> I am trying to write a shell script that will move a file, create a new
> file, and get a file with ftp.
> 
> Is thier any way that my shell script can send comands to the ftp program or
> is thier a way around using ftp.

Both.

You can send commands to the ftp program directly using either via a "here
document" or by piping it to the program directly.

An example of a here document is as followed.

        ftp localhost << TheEnd
        user anonymous
        pass [EMAIL PROTECTED]
        get file.tar.gz
        quit
        TheEnd

Everything between the first and the last line will be used as the input to the
ftp program. The string "TheEnd" is used to indicate the end of the here
document, you may use any string you wish. Read the bash man pages for details.

Another way is to pipe the commands in directly. This is not commonly used as
it's difficult to read and is a little more complicated. The following command
is a simple example.

        echo -e "help\nquit" | ftp localhost


Since programs like "ftp" are designed for interactive uses and not for use in
a script, you may find it more convenient and flexible to use a non-interactive
command line download program such as "got_it" instead when writing scripts. You
can find "got_it" and many other programs like it in the application index
section of http://freshmeat.net or at ftp://metalab.unc.edu/pub/Linux

Cort
[EMAIL PROTECTED]

Reply via email to