[Next] [Previous] [Up] [Top] [Contents] [Index]

Chapter 13: Connecting to Remote Systems

13.1 Transferring Files

13.1.1 ftp

ftp (File Transfer Protocol) can be used to transfer files to and from a remote system on which you have an account, and to manipulate the remote file system. The command format is:

% ftp [-n] [-i] [host] 

If you specify host on the command line, you will be prompted for your (remote) username and password, and login will proceed. The option -n inhibits autologging on those systems on which it is enabled. The option -i eliminates prompting by the system, which can be tiresome when you're transferring many files.

[Missing image]Some commands available in ftp are described here; for a complete list, see the man pages for ftp.

user username password

Identification for the remote system. If auto-log is enabled, you will be prompted automatically for the username and password. If you don't specify the password, it will prompt you.

bin or binary

Set transfer mode to binary image transfer.

ascii

Set transfer mode to ASCII (for text files).

put local_file [remote_file]

Transfer a local file to the remote system. If the remote filename is not specified, the local filename is used.

mput local_files [remote_files]

Similar to put, but you can use standard wildcard characters to transfer a series of files at a time.

get remote_file [local_file]

Transfer a remote file to the local system. If the local file name is not specified, it is given the name on the remote machine.

mget remote_files [local_files]

Similar to get, but you can use standard wildcard characters to transfer a series of files at a time.

help [command]

Display information about the meaning of command. If no command is specified, ftp displays a list of the commands.

quit

Terminate the ftp session with the remote server and exit ftp.

open host

Establish connection with remote host. Needed if host was not specified on command line.

close

Close connection with remote host and return to ftp prompt. Doesn't exit ftp.

dir [remote_directory] [local_file]

Print listing of the directory contents of the remote directory and optionally put the output in local_file.

cd remote_directory

Change working directory on the remote machine to remote_directory.

lcd [directory]

Change working directory on the local machine. If no directory is specified, your home directory is used.

delete remote_file

Delete the file remote_file on the remote system.

! shell_command

Run a shell command without exiting ftp.

The following is an example ftp session where first one ASCII file, then a few binary files, are transferred from one UNIX machine to another. The username is unnecessary if the assumed one is correct. The password, as usual, is not displayed.

<fsui02> ftp cdfsga

Connected to cdfsga.fnal.gov.

220 cdfsga.fnal.gov FTP server ready.

Name (cdfsga:aheavey):

331 Password required for aheavey.

Password:

230 User aheavey logged in.

ftp> ascii

200 Type set to A.

ftp> put README

200 PORT command successful.

150 Opening ASCII mode data connection for 'README'.

226 Transfer complete.

local: README remote: README

121 bytes sent in 0.00091 seconds (1.3e+02 Kbytes/s)

ftp> bin

200 Type set to I.

ftp> mput appx*

mput appx_MH.ps? y

200 PORT command successful.

150 Opening BINARY mode data connection for 'appx_MH.ps'.

226 Transfer complete.

local: appx_MH.ps remote: appx_MH.ps

63902 bytes sent in 0.33 seconds (1.9e+02 Kbytes/s)

mput appx_awk.ps? y

200 PORT command successful.

150 Opening BINARY mode data connection for 'appx_awk.ps'.

226 Transfer complete.

local: appx_awk.ps remote: appx_awk.ps

56271 bytes sent in 0.24 seconds (2.2e+02 Kbytes/s)

mput appx_convrt.ps? n

mput appx_exmpl.ps? n

mput appx_impatient.ps? n

mput appx_login.ps? n

mput appx_ups.ps? y

200 PORT command successful.

150 Opening BINARY mode data connection for 'appx_ups.ps'.

226 Transfer complete.

local: appx_ups.ps remote: appx_ups.ps

107683 bytes sent in 1.3 seconds (83 Kbytes/s)

ftp> quit

221 Goodbye.

<fsui02>

[Missing image]Note that the CERN utility zftp (z for Zebra) is available for transferring FZ and RZ files (ntuple files) between systems[69]. To use zftp, it must be installed on the server system, and you need to set up CERN library during the session (setup cern).

13.1.2 rcp

Another way to transfer files is with the rcp utility (stands for remote copy). You can use this command if both local and remote hosts support rcp protocol. The basic format is:

% rcp [options] file1 file2 

where file1 and file2 are the source and destination filenames, respectively; or

% rcp [options] file1 file2 ... directory

where the files listed are to be copied to the directory. On a UNIX system the format of a remote directory or filename is hostname:path, and the MultiNet implementation is consistent with VMS usage, namely hostname::path (note the double colon). If only filenames are given, they are interpreted relative to your home directory. Both the source and the destination may be on nodes other than the current machine.

The available options are:

-p

Give each copy the same modification times, access times, and modes as the original file.

-r

Copy each subtree rooted at file1, file2, etc. (for those that are directories); in this case the destination (last argument) must be a directory.

rcp does not prompt for passwords. Your current local user name must exist on the remote host and allow remote command execution by rsh. rsh is a utility that connects to a remote host and either executes a specified command or logs you on via rlogin (see section 13.3).

[Missing image]More information is available in the rsh and rcp man pages.

When you are using rcp between VMS and UNIX, you must protect special characters from local interpretation by enclosing them in quotes. An example command to copy a file $HOME/prog1.c from UNIX to the VMS node FNALV is:

% rcp prog1.c fnalv:"[.c]prog1.c" 

Here is an example showing how to copy a file from remote UNIX node FNSG01 to the home directory on the VMS node ($ represents the VMS prompt):

$ rcp fnsg01::"/usr/products/bufio/v1_00/src" bufio.src 

[Missing image]If you are using the C shell family, rcp will not work if your .cshrc or .login on UNIX, or your LOGIN.COM file on a remote VMS host, executes interactive or output-generating commands. You should check for non-interactive access, and exit before such commands are executed, as is done for a UNIX system in the FUE default .cshrc file. The lines in .cshrc that check this are the following:

# Place any items that you want executed even for non-interactive use here
# Skip if not interactive shell
if ( $?USER == 0 || $?prompt == 0 ) exit

On a VMS system, check for OTHER (TCP/IP is not NETWORK):

$ IF (F$MODE () .EQS. "OTHER") THEN $ EXIT 

Although you can specify a username and password with rcp (see the local man pages or HELP), you can also have a kind of "proxy login" by creating a special file (named .rhosts) on the remote machine containing the names of the systems and users on those system that should be allowed access.

13.1.3 The .rhosts File

To use many of the file transfer utilities, you need to set up what is known as a .rhosts file on the remote machine. This file must include a list of the names of the systems to be allowed remote access without login, and the usernames, where each system-username combination is separated by a space. If the username is left off, it is assumed to be the same as on the current system. If there are problems with name servers, you can be most assured that your address will be understood if you specify three lines for each connection requested:

1) one line with the complete Internet address,

2) one with the Internet number[70], and

3) one with the local name.

An example .rhosts file showing a single connection in the three specified formats:

fnsg01.fnal.gov 
131.225.8.178
fnsg01 judy

When writing a .rhosts file on a UNIX host to allow access via remote commands (known as r-commands[71]) from a VMS cluster, you must include an entry for each cluster member and username from which you might access the UNIX host.

The following command line is an example of the command to copy a FINGER.PLN file from an account on FNALA to the file .plan in the same person's account on the UNIX node FNSG01. In order for this example to work, there must be a file named .rhosts on FNSG01 containing a line fnala.fnal.gov, and the username must be the same in both places.

$ RCP FINGER.PLN FNSG01::.PLAN 

where $ is the VMS prompt.


[69] [Missing image]zftp is known to be likely to break in the AFS environment.
[70] Use nslookup node to get the number. On VMS, you must enter MULTINET NSLOOKUP hostname.
[71] r-commands execute on remote hosts, and use .rhosts for authentication. They are variants of UNIX commands without the "r", and include for example rsh (remote sh) and rlogin (remote login).