Getting RPMs Using Command-Line Anonymous FTP





Getting RPMs Using Command-Line Anonymous FTP

The Web-based method in the last section transparently uses anonymous FTP. Anonymous FTP enables you to log in and download files from a FTP server using the username anonymous or the shorter username ftp and a password that matches your e-mail address. This way anyone can access the data. Let's illustrate this with an example of using anonymous FTP to download the SSH package from download.fedora.redhat.com.

1.
First, we issue the FTP command targeting download.fedora.redhat.com at the command line:

[[email protected] tmp]# ftp download.fedora.redhat.com
Trying 66.187.232.35...
Connected to download.fedora.redhat.com (66.187.232.35).
220 Fedora FTP server ready. All transfers are logged.
Name (download.fedora.redhat.com:root): anonymous
331 Please specify the password.
Password:
230 Login successful. Have fun.
Using binary mode to transfer files.
ftp> pwd
257 "/"
ftp> ls
227 Entering Passive Mode (66,187,232,35,57,155)
150 Here comes the directory listing.
drwxr-xr-x    3 ftp       ftp           4096  Oct 29 15:59 pub
226 Directory send OK.
ftp>

2.
After we've logged in, we can use the help command to see what options we have at our disposal:

     ftp> help
     Commands may be abbreviated. Commands are:

  !             Debug            mdir           sendport      Site
  $             dir              mget           put           size
  account       disconnect       mkdir          pwd           status
  append        exit             mls            quit          struct
  ascii         form             mode           quote         system
  bell          get              modtime        recv          sunique
  binary        glob             mput           reget         tenex
  bye           hash             newer          rstatus       tick
  case          help             nmap           rhelp         trace
  cd            idle             nlist          rename        type
  cdup          image            ntrans         reset         user
  chmod         lcd              open           restart       umask
  close         ls               prompt         rmdir         verbose
  cr            macdef           passive        runique       ?
  Delete        Mdelete          proxy          Send

ftp>

The commands you'll most likely use are listed in Figure.

FTP Commands

Command

Description

binary

Copy files in binary mode.

cd

Change directory on the FTP server.

dir

List the names of the files in the current remote directory.

exit

Bye bye.

get

Get a file from the FTP server.

lcd

Change the directory on the local machine.

ls

Same as dir.

mget

Same as get, but you can use wildcards like *.

mput

Same as put, but you can use wildcards like *.

passive

Make the file transfer passive mode.

put

Put a file from the local machine onto the FTP server.

pwd

Give the directory name on the local machine.


3.
By using the Web browsing feature on the Web site ahead of time, I know that the Fedora Core 2 RPMs are located in the pub/fedora/linux/core/2/i386/os/Fedora/RPMS/ directory and will use the cd command to change my directory to there. We can use the ls command to get a listing of files in this directory:

ftp> cd pub/fedora/linux/core/2/i386/os/Fedora/RPMS/
250 Directory successfully changed.
ftp> ls open*
227 Entering Passive Mode (66,187,232,35,58,3)
150 Here comes the directory listing.
...
...
-rw-r--r--   ... ... 184281 Oct 28 23:29 openssh-3.6.1p2-
34.i386.rpm
...
...
226 Directory send OK.
ftp>

4.
Next we get the file we need and place it in the local directory /usr/rpm. The hash command prints # hash signs on the screen during the download:

ftp> hash
Hash mark printing on (1024 bytes/hash mark).
ftp> lcd /usr/rpm
Local directory now /usr/rpm
ftp> get openssh-3.6.1p2-34.i386.rpm
local: openssh-3.6.1p2-34.i386.rpm remote: openssh-3.6.1p2-
34.i386.rpm
227 Entering Passive Mode (66,187,232,35,58,25)
150 Opening BINARY mode data connection for openssh-3.6.1p2-
34.i386.rpm (184281 bytes).
##############################################################
##############################################################
#######################################################
226 File send OK.
184281 bytes received in 3.41 secs (53 Kbytes/sec)
ftp>

Note

You can also use wildcards to download the RPMs you need using the mget command. You'll be prompted for each of the matching RPM files. In the next example, we just aborted this download by typing n.


ftp> mget openssh-3.6*
mget openssh-3.6.1p2-34.i386.rpm? n
ftp>

5.
Finally we use the exit command to leave FTP:

ftp> exit
221 Goodbye.
[email protected] tmp]#


     Python   SQL   Java   php   Perl 
     game development   web development   internet   *nix   graphics   hardware 
     telecommunications   C++ 
     Flash   Active Directory   Windows