Notice! This document is currently in Archived status.
The content of this document may be incorrect or outdated.

Print this article Edit this article

Sending files to a remote host while in ftp?

Purdue Engineering Computer Network

To send one file from the local host to the remote host you can use either the send or the put command.

To send multiple files to the remote host use the mput command. mput takes the files in the list and moves them to the remote system.

The files to be sent are assumed to be in your current directory unless you specify otherwise. Files will be placed in your current directory on the remote hosts unless you specify otherwise.

Examples

1. To send a single file from your current directory on the local host to the current directory on the remote host:

ftp> send foo

This copies the file foo from your current directory on the local host to your current directory on the remote host.

If you don't give a name for the remote-file the name of the local-file you are copying is used to name the remote-file.

2. To use file pathnames to define both the local-file and the remote-file:

ftp> put summaries/oct wkly_summaries/month10

This copies the contents of the file oct, which is in the sub-directory summaries, which is in your current directory on the local host, to the file month10 in the sub-directory wkly_summaries, which is in your login directory on the remote host.

3. To send multiple files to a remote host:

ftp> mput list of files

We will try to put a group of files. We will explicitly put two filenames on the command, just to show you that it can be done.

ftp> mput foo table.c
mput foo? yes
200 PORT command successful.
150 ASCII data connection for fo (127.0.0.1,1139).
226 Transfer complete.
mput table.c?
yes
200 PORT command successful.
150 ASCII data connection for table.c (127.0.0.1,1141).
226 Transfer complete
ftp>

Note that the command we just gave, mput foo table.c, does not mean "put foo on the remote system with the filename table.c; as it would if it were a simple put command. It means "copy all the files on the command line to the remote system, in the current remote directory, without changing their names".

ftp normally asks you whether or not you want to transfer each file; you have to type y (or yes, or RETURN) to transfer the files. Typing n (or no) cancels the transfer.

There are a few things to remember:

  • Remember that you don't get to specify a name for the destination file. All the names on the command line are interpreted as source files. It's particularly tempting to try to copy a group of files into a directory; what out for this! You cannot use a command like the following:

    ftp> mput ch*.txt book

    where book is the name of a remote directory. Instead, you must first use cd to change into the remote directory.

    ftp> cd book
    . . .
    ftp> mput ch*.txt

  • You cannot use mput or mget (or for that matter, the regular get and put commands) to copy a directory. You can only use them to copy groups of plain files. Copying a directory yields unpredictable results. If you need to transfer a directory, create an archive of some sort and transfer the archive.

Last Modified: Dec 19, 2016 11:12 am US/Eastern
Created: May 31, 2007 1:13 pm GMT-4 by admin
JumpURL: https://eng.purdue.edu/jump/94fc3