-->
Previous Table of Contents Next


Local Commands While in FTP

The ! character is used to pass a command to the command shell on your local computer while you’re in FTP. This can be very useful if you need to do something while you’re in the midst of an FTP session. Suppose that you need to create a directory to hold received files. If you enter !mkdir new_dir, Linux makes a directory named new_dir in your current local directory.

A Sample FTP Session

Listing 30.1 shows a short FTP session.

Listing 30.1 Making an FTP Connection and Getting a Directory Listing


$ ftp opus

Connected to opus.

220 opus FTP server (Linux opus 2.0.6 #4 Mon Nov 11 16:01:33 CDT 1996)

ready.

Name (opus:smith): smith

Password (opus:smith): password

331 Password required for smith.

230 User smith logged in.

Remote system type is UNIX.

Using ASCII mode to transfer files.

ftp> dir

200 PORT command successful.

150 Opening ASCII mode data connection for /bin/ls.

total 8

-rw-r--r--  1 root     daemon       1525 Sep 29 15:37 README

dr-xr-xr-x  2 root     wheel         512 Jun 24 11:35 bin

dr--r--r--  2 root     wheel         512 Jun 24 11:18 dev

dr--r--r--  2 root     wheel         512 Jun 24 11:24 etc

dr-xr-xr-x  4 root     wheel         512 Sep 29 15:37 pub

dr-xr-xr-x  3 root     wheel         512 Jun 24 11:15 usr

-r--r--r--  1 root     daemon        461 Jun 24 13:46 welcome.msg

226 Transfer complete.

433 bytes received in 0.027 seconds (16 Kbytes/s)

ftp> get README

200 PORT command successful.

150 Opening ASCII mode data connection for README (1525 bytes).

226 Transfer complete.

local: README remote: README

1561 bytes received in 0.0038 seconds (4e+02 Kbytes/s)

ftp> quit

221 Goodbye.

$

In the preceding example, a user opens an FTP session to the host opus and logs in as smith. The remote FTP server prompts for the password, which the user types (the password doesn’t appear on-screen). ftp then logs smith in to the remote system and displays the ftp> prompt for interactive mode commands. The user tells ftp to list the remote directory with the dir command and then transfers the file README with the get command. When finished with the FTP session, the intrepid user then logs out with the quit command and is returned to the local Linux shell prompt.

A Sample Anonymous FTP Session

In the previous section, you saw a user initiate an FTP session with a system and look at some directories. The user had a valid username and password on the remote system. Now look at an anonymous FTP session to a major software archive site on the Internet. Listing 30.2 is very similar to Listing 30.1, but it has some interesting differences.

Listing 30.2 Performing an Anonymous FTP Connection


$ ftp ftp.uu.net

Connected to ftp.uu.net.

220 ftp.UU.NET FTP server (Version wu-2.4(1) Wed Nov 13 15:45:10 EST 1996)

ready.

Name (ftp.uu.net:bubba): anonymous

331 Guest login ok, send your complete e-mail address as password.

Password: your_e-mail_address

230-

230-                Welcome to the UUNET archive.

230-   A service of UUNET Technologies Inc, Falls Church, Virginia

230-   For information about UUNET, call +1 703 204 8000,

230-  or see the files in /uunet-info

230-

230-   Access is allowed all day.

230-   Local time is Wed Nov 13 15:53:02 1996.

230-

230-   All transfers are logged with your host name and email address.

230-   If you don’t like this policy, disconnect now!

230-

230-   If your FTP client crashes or hangs shortly

230-   after login, try using a

230-   dash (-) as the first character of your password.

230-   This will turn off the informational messages which may

230-    be confusing your ftp client.

230-

230-Please read the file /info/README.ftp

230-  it was last modified on Mon Nov 11 17:39:53 1996 - 2 days ago

230 Guest login ok, access restrictions apply.

ftp>

ftp> dir

200 PORT command successful.

150 Opening ASCII mode data connection for /bin/ls.

total 4149

drwxr-sr-x   2 34   0             512 Jul 26  1992 .forward

-rw-r--r--   1 34   uucp            0 Jul 26  1992 .hushlogin

-rw-r--r--   1 34   archive        59 Jul 31  1992 .kermrc

-rw-r--r--   1 34   archive         0 Jul 26  1992 .notar

drwx--s--x   5 34   archive       512 Jul 23 19:00 admin

lrwxrwxrwx   1 34   archive         1 Jul 26  1992 archive ->.

drwxrws--x   4 0    archive       512 Apr 20 16:29 bin

lrwxrwxrwx   1 34   archive        23 Sep 14  1993 by-name.gz ->

index/master/by-name.gz

lrwxrwxrwx   1 34   archive        23 Sep 14  1993 by-time.gz ->

index/master/by-time.gz

-rw-r--r--   1 34   archive   90112 Apr 26  1991 compress.tar

lrwxrwxrwx   1 0   archive       9 Jul 23 18:50 core -> /dev/null

drwxrws--x   2 0   archive     512 Jul 26  1992 dev

drwxrwsr-x  21 34  archive    1024 Sep 29 15:18 doc

drwxrws--x   6 0   archive     512 Apr 14 16:42 etc

lrwxrwxrwx   1 34  archive      31 Dec  8  1993 faces ->

/archive/published/usenix/faces

drwxrwsr-x   2 34   archive       512 Jul 26  1992 ftp

drwxrwsr-x   4 34   archive       512 Sep 29 10:34 government

drwxrwsr-x  18 34   archive      1024 Sep 29 10:28 graphics

-rw-rw-r--   1 27   archive    798720 Jul 11 20:54 gzip.tar

lrwxrwxrwx   1 34   archive        17 Jul 26  1992 help ->

                                                   info/archive-help

drwxrwsr-x  20 34   archive      1024 Dec  2  1993 index

drwxrwsr-x  19 34   archive       512 Sep 29 10:30 inet

drwxrwsr-x   4 34   archive       512 Sep 29 15:36 info

drwxrwsr-x  25 34   archive       512 Sep 29 10:29 languages

drwxrwsr-x   4 34   archive       512 Sep 29 10:28 library

drwx--s--x   2 0    0            8192 Jul 26  1992 lost+found

lrwxrwxrwx   1 34   archive        20 Aug  2  1992 ls-lR.Z ->

index/master/ls-lR.Z

lrwxrwxrwx   1 34   archive        21 Sep 14  1993 ls-lR.gz ->

index/master/ls-lR.gz

lrwxrwxrwx   1 34   archive        21 Aug  2  1992 ls-ltR.Z ->

index/master/ls-ltR.Z

lrwxrwxrwx   1 34   archive        22 Sep 14  1993 ls-ltR.gz ->

index/master/ls-ltR.gz

drwxrwsr-x  24 34   archive      1024 Sep 29 15:10 networking

drwxrwsr-x   2 34   archive       512 Aug 10 09:26 packages

d--xrws--x  17 34   archive       512 Sep 26 12:29 private

drwxrwsr-x  25 34   archive      1536 Sep 29 15:30 pub

drwxrwsr-x  17 34   archive      1024 Sep 29 15:38 published

lrwxrwxrwx   1 34   archive        10 Jul 26  1992 sco-archive ->

                                                   vendor/sco

drwxrwsr-x  20 34   archive       512 Sep 29 04:18 systems

drwxrwxrwx  14 34   archive      1536 Sep 29 15:36 tmp

lrwxrwxrwx   1 34   archive        17 Jul 26  1992 unix-today ->

vendor/unix-today

lrwxrwxrwx   1 34   archive        17 Jul 26  1992 unix-world ->

vendor/unix-world

drwxrwsr-x  36 34   archive      1024 Sep 29 15:29 usenet

drwxrws--x   6 0    archive       512 Oct 22  1992 usr

lrwxrwxrwx   1 34   archive        16 Aug  2  1992 uumap

                                                   -> networking/uumap

-rw-rw-r--   1 34   archive   3279895 Sep 28 21:05 uumap.tar.Z

drwxrwsr-x   3 210  archive      2560 Sep 29 15:36 uunet-info

drwxrwsr-x  64 34   archive      1536 Sep 29 10:29 vendor

226 Transfer complete.

3257 bytes received in 0.76 seconds (4.2 Kbytes/s)

ftp>

ftp> cd systems/unix/linux

250-Files within this subtree are automatically mirrored from

250-tsx-11.mit.edu:/pub/linux

250-

250 CWD command successful.

ftp>

ftp> binary

200 Type set to I.

ftp> get sum.Z

200 PORT command successful.

150 Opening BINARY mode data connection for sum.Z (80959 bytes).

226 Transfer complete.

local: sum.Z remote: sum.Z

80959 bytes received in 5.6 seconds (14 Kbytes/s)

ftp> quit

221 Goodbye.

$


Previous Table of Contents Next