MSSL Basic User Note #11:

Transferring files

Philip Smith 19/10/95 V0.0

This document:



The File Transfer Program/Protocol (ftp) is a program used on TCPIP platforms to transfer files (programs and data) from computer to computer. The MSSL DECs (VMS and Unix), most Unix machines, and some PCs and Macs have it installed.


General case

In a normal ftp session, you ftp to the remote machine with
	ftp remote-machine
The remote machine will prompt for a username and password for the remote machine.
If you get your username or password wrong you will not be allowed to do very much until you use
	user login-name
after which you will be prompted for your password again. (You could of course just quit and try the whole ftp again if this is simpler.)

You will be in your home directory. Use

to look for the file(s) you would like to transfer or the directory you would like to transfer file(s) to.

Next select a file transfer type. If the file is just a plain text ascii file, use:

or if the file is a binary file (or you are just not sure), use:
Using ascii will make sure that new-lines are converted to the right type of new-line for the system in question. Remember compressed files are usually binary and postscript, uuencoded and binhex programs are ascii. Then you can get a file by typing
	get filename
or if you would like to call the file something else locally,
	get filename local-filename
or put a file by typing
	put filename
	put filename remote-filename
If you would like to get a number of files use
	mget files
where files can contain a wildcard.
You will be prompted yes/no for each file but you can toggle this off (and then back on again) by typing

To close the connection type:

you can then open another connection using
	open remote-machine
or just quit with


Here is an example.

Say we want to transfer a file letter.tex from mssls7 to mssly3
First go into the directory on the machine you would like the file to be (mssly3):

	cd letters
and type
	ftp mssls7
The remote machine (in this case mssls7) will prompt you for your login name and password for that machine.
	Connected to
	220 FTP server (SunOS 4.1) ready.
	Name (mssls7:your_name): your_name
	331 Password required for your_name.
If you logged in correctly you will get the following message and prompt:
	230 User your_name logged in.
Now change directory to get to where letter.tex resides:
	cd ~/docs/tex
Because the letter is a TeX file (and is therefore human-readable), you should choose type ascii:
and then get the file:
	get letter.tex
Finally you can close the connection and quit:
or just say quit or bye:

If you wanted all your tex files in ~/docs/tex you should do as above but instead of the `get' command first type:

and the:
	mget *.tex


VMS ftp is a little different to the standard UNIX ftp. Only the version numbers will cause a real problem. What can happen is if you transfer files from VMS to Unix using mget, the files can end up on the Unix account in uppercase and with a semicolon number (e.g., `;1') at the end. If this happens you can either do the following to a directory full of VAX files under Unix:
	foreach FILE ( * )
	  mv $FILE `echo $FILE | cut -f 1 -d ';' | tr A-Z a-z`
or just log onto VMS, ftp to Unix and `put' them from VMS to Unix (rather than logging onto Unix, ftping VMS and `get'ting then from VMS to Unix).

VMS disks and directory names aren't much of a problem just use cd (e.g.,

	cd disk$xray:[user.files]
	cd morefiles

Here is an example.

You want to transfer all your TeX documents on mssla3 to mssly3.
You know that on the VAX the filenames have version numbers and you don't want to convert them when they get to mssly3 so you decide to `put' the files from mssla3 to mssly3 (rather than get them from mssla3 to mssly3).

	set def disk$u1:[your_name.letters]
	ftp mssly3

	220 FTP server (OSF/1 Version 5.60) ready.
	Connected to 
	Name (MSSLY3:your_name): your_name
	331 Password required for your_name.
	Password: your_password
	230 User your_name logged in.
	FTP> cd ~/docs/tex
	250 CWD command successful.
	FTP> mput *.*
	FTP> close
	221 Goodbye.
	FTP> quit

Further information

To change your local directory while in ftp use:
To execute something in a shell while in ftp use an exclamation mark, for example to check your local directory use:
Typing `help' at the ftp prompt will give a list of commands available in ftp on the remote machine (this will be different for different machines).

Other commands which might prove useful (if available) are:

For more detailed information
	man ftp

Anonymous ftp

Many sites have an anonymous-ftp server which allows (almost) anyone to ftp there and get (and sometines put) files.


as the Name
and your mail address
as the password.

Anonymous ftp can also be accessed with WWW browsers like Netscape using URLs of the form

The .netrc file

To store information on frequently used ftp addresses, use a ~/.netrc file (i.e. a .netrc file in your home directory).

This file stores the machine name, login, password and lists of ftp commands to execute at that site.

Do NOT store any passwords other than anonymous ones in this file An example file is:

	login anonymous

	login anonymous
	macdef init
	cd /pub/OS/Linux/PEOPLE/Linus/v1.2
	get linux-1.2.13.tar.gz

	login anonymous
This example contains three entries the first and thirs of which just save the user from typing in the anonymous login name and email address as password.

The second shows the macdef command which defines a macro for frequently used command sequences. In this case the macro is a special one called `init' and so will run automatically after typing `ftp'.
This can be used in conjunction with the `at' command to ftp something automatically at night when network traffic is lower.
To do this create a file (for this example called `go_ftp') containing just

	ftp sitename
and make it executable
	chmod 755 go_ftp
Then set off the go_ftp command at a suitable time:
	at 0400 ./go_ftp
and the next time it gets to 0400, the go_ftp file will run the ftp command it contains and ftp will look in your .netrc file, see the `macdef init' and run the commands therein automatically.

Entries in the .netrc file must be separated by a blank line as in the example and MUST NOT CONTAIN ANY REAL PASSWORDS or your .netrc file will be permanently removed.

For more information

	man netrc

PC diskettes

The linux DOS-like commands are like the MSDOS commands but with an `m' in front. To copy files to a PC diskette, place the diskette in the PC's floppy drive and type
	mcopy  file  a:
To copy files from a PC diskette to the current directory, use
	mcopy  a:file  .
where the dot `.' just means the current directory and could be replaced with a different directory. To delete files on a floppy use
	mdel  a:file
To do a dir use:
	mdir  a:
The full list of DOS-like commands is For more help do
	man mtools
Note that when using wildcards (`*' and `?') you must use single quotes around the wildcard filename, e.g.,
	mcopy  a:'*.*'  ~/dosprogs/
Warning DOS ascii files use CARRIAGE-RETURN (0D) LINEFEED (0A) to mark the end of a line while UNIX uses just a LINEFEED (0A).
Problems with this will show up as something like `^M', `LF' or `LINEFEED' in editors.
When copying DOS ascii files to Unix for use under Unix you will probably want the files' `new-lines' converted during to copy to be Unix-like. If this is the case use the `it' switch with mcopy, e.g.,
	mcopy  -t  a:letter.doc  .

Netscape and URLs

The main World Wide Web browser used at MSSL is Netscape. This is an X-Windows program so you must be using a computer with an X-display running.

A URL is a Universal Resource Locator - a unique address to specify the type of file, the machine it is on (anywhere in the world), the path to the file (the directories) and the filename itself.

The URL of this document might be is:
To access a URL, select `Open' in Netscape and type in the URL or type it into the `Location' Window (if there is one showing) and press ENTER.

For example, if you want the program make-3.74.tar.gz in the /gnu directory at you would use the URL

P.J.Smith ---