Transferring Files
ftpFtp (for File Transfer Protocol) is the standard UNIX
mechanism for transferring files between remote machines.
Promiscuous Ftp connections are allowed out, but
not in to MSRI. To
ftp files into MSRI from a remote site you must use
S/KEY for authentication.
If you do not already have an account at MSRI,
you may ftp to ftp.msri.org and login as
ftp. You can then put your files in
/incoming, and a member of the computing staff will help
you retrieve them upon your arrival.
Note:Unfortunately, the ftp client for the
Macintosh, Fetch was developed by NCSA, and both NCSA and
Apple began loosing their best Internet programmers about the time
that firewalls became
wide-spread. Consequently, Fetch doesn't understand
firewalls, and it is impossible to use fetch to transfer
files between MSRI and the outside world.
One work-around is to use Netscape on the Macs. If the
remote site is serving both ftp and http
(World-Wide Web), you can use Netscape to open a URL like
ftp://ftp.msri.org, for
example, in order to retrieve files from the anonymous
ftp archive here at MSRI. Another is to use ftp under Unix between MSRI and
the Internet, and use Fetch between
a MSRI Mac and a MSRI Unix machine.
ftp program by typing:ftp
remoteSite. You will then be prompted for a login ( your
own at the remote site, or ftp, if you don't have one and
are using ftp anonymously) and password ( your own at the
remote site, or yourMSRIloginID@msri.org, if
you don't have one and are using ftp anonymously).
The ftp program is interactive; it presents you with a
ftp> prompt, and waits for you to type commands.
For historical reasons, ftp wakes up in text
mode which will garble any non-text file, as well as many non-English
text files; to guard against this, issue the command ftp>
binary to toggle ftp into so-called
Image mode.
Since I am an impatient person, I also like to tell it ftp>
hash so that it will print out hash marks as the file transfer
progresses.
Ftp's two most basic commands
are
ftp> put filename
and
ftp> get filename
for receiving and sending files respectively.
You can navigate within file systems using the ftp
commands
ftp> lcd some/where
locally and
ftp> cd somewhere/else/remote
remotely to change directories.
Within ftp the command
ftp> ls
will list remote files.
There are also commands
We will use the UNIX utility
For example,
We can remind ourselves of the contents of the archive
To save space, there is the
Many, but, alas, not all, sites support the completely analogous and
vastly superior GNU utilities
Thus, with GNU
In more detail, first
Next, generate a one-time
password in response on your local machine.
Once authenticated, at the
respond with your MSRI password, and proceed as before.
With any of these methods you may encounter a problem with line
terminators. The symptoms are either unwanted control characters in
your file, visible as
ftp> mget regularExpression
and
ftp> mput regularExpression
which allow you to use wildcards to
retrieve or send all files matching regularExpression.
For example,
ftp> mget *.tex
will query you if you wish to retrieve
each file whose names end in .tex. If you are confident
about your regular expression, you can suppress the prompting
before you begin with the prompt toggle in ftp.
Control-C aborts ftp commands, and
ftp> bye
exits ftp.
myPrompt% ftp godel.geom.umn.edu
Connected to godel.geom.umn.edu.
220 godel FTP server (SunOS 4.1) ready.
Name (godel.geom.umn.edu:joe): joe
331 Password required for joe.
Password:
230 User joe logged in.
ftp> hash
Hash mark printing on (8192 bytes/hash mark).
ftp> binary
200 Type set to I.
ftp> ls
200 PORT command successful.
150 Opening ASCII mode data connection for file list.
foo
bar
baz
bash_defaults
226 Transfer complete.
547 bytes received in 0.18 seconds (2.9 Kbytes/s)
ftp> get foo
200 PORT command successful.
150 Opening BINARY mode data connection for foo (13 bytes).
#
226 Transfer complete.
local: foo remote: foo
13 bytes received in 0.02 seconds (0.64 Kbytes/s)
ftp> mget b*
mget bar? y
200 PORT command successful.
150 Opening BINARY mode data connection for bar (12 bytes).
#
226 Transfer complete.
local: bar remote: bar
12 bytes received in 0.018 seconds (0.65 Kbytes/s)
mget bash_defaults/.bash_alias? n
mget bash_defaults/.bash_login? n
mget bash_defaults/.bashrc? n
mget baz? y
200 PORT command successful.
150 Opening BINARY mode data connection for baz (13 bytes).
#
226 Transfer complete.
local: baz remote: baz
13 bytes received in 0.017 seconds (0.77 Kbytes/s)
ftp> bye
Copying Entire Directory Trees
If you want to transfer entire directory trees, you can save
work by first creating a tar archive, compressing
it to save transfer time, and then transfer the compressed archive.
tar archive.
tar archive.
tar archive with ftp.
tar archive.
tar archive.
tar to ``roll up'' an entire
directory tree into a single file. We'll then transfer that file via
ftp, and reverse the tar process at the
other end. Be aware that tar archives can be quite large
- as large as the directory tree you're moving. If you're trying to
copy a 5M directory, but you have a 3M quota at the remote site, your
tar file won't fit!
Tar (for Tape Archive and Restore) was originally written
to do tape backups. Since then it has been superseded for backups,
but it remains the best tool for condensing sprawling masses of
files into a single, easily handled file.
Tar has three basic modes, create - flag c,
extract - flag x, list - flag t, for
creating, extracting and listing the contents of an archive.
Tar has many other flags (see the tar man
page), but only one need concern us here: f, for
file. The mode flags must come first, and, since it takes a
filename as an argument, the f flag should come last. In
create mode, tar itself takes as an argument a list of
the directories and files that you wish to archive. By convention,
tar archives have the extension .tar.
tar -cf foo.tar bar baz
creates an archive called foo.tar containing the file
bar and the directory baz. Similarly,
tar -cf texFiles.tar *.tex
creates an archive called texFiles.tar containing all
files with extension .tex in the current directory.
foo.tar using list mode:
tar -tf foo.tar
would report:
bar
baz/
baz/quux
If we used the verbose flag, v, we would find out a little
more, analogous to the output of ls -lg:
yourPrompt% tar -tvf foo.tar
-rw-r--r-- joe/wheel 13 Sep 5 16:01 1994 bar
drwxr-xr-x joe/wheel 0 Sep 5 16:01 1994 baz/
-rw-r--r-- joe/wheel 14 Sep 5 16:01 1994 baz/quux
We can recover all of our archived TeX files as follows:
tar -xf texFiles.tar
compress command. It comes in
two flavors, compress and uncompress, the
use of which is pretty straightforward:
compress texFiles.tar
replaces the large texFiles.tar with a smaller file
texFiles.tar.Z (compressed files must have the
extension .Z to be recognized) and
uncompress texFiles.tar.Z
reverses the process, replacing the small texFiles.tar.Z with
the large texFiles.tar.
gzip and
gunzip for compressing and uncompressing files. While
gzip can read .Z files, it creates (smaller)
files with the extension .gz. Moreover, the GNU version
of tar, sometimes called gnutar, understands
the .gz file format, and when given the z
flag, can combine gzip compression and decompression with
tar archive creation and extraction.
tar, the single command
tar -czf texFiles.tar.gz *.tex
is equivalent to pair of commands
tar -cf texFiles.tar *.tex; compress texFiles.tar
and the single command
tar -xzf texFiles.tar.gz
is equivalent to pair of commands
uncompress texFiles.tar.Z; tar -xf texFiles.tar
Authenticated
Just as with ftp into MSRIrlogin or telnet, to
ftp into MSRI, from outside our network, you connect to
the firewall and use S/KEY for
authentication.
ftp to the firewall machine,
msri.org.
Username, and then presented with an S/KEY challenge.
ftp.
MSRI> prompt on the firewall,
type user username@machinename, where
username is the name of your MSRI account, and
machinename is the name of some machine at MSRI, e.g. the
one on your desk.
Transferring Files Among DOS/Windows, Mac, and
UNIX
There are several ways to transfer files between the UNIX environment
and the Mac and PC environments. One can use the disc drives on either
the Linux PC's, or Macs.
^M and the like, or the appearance
that your file is all one terribly long line. To cope with these
problems, use the UNIX commands mac2unix,
unix2mac, dos2unix, and
unix2dos which translate line terminators.
Using DOS diskettes in a Linux PC
mdir A:
mcopy file A:
mcopy A:file.ext .
mdel A:file.ext
eject
File Transfer Between Macs and UNIX, using a Mac
/u/username;
Last modified by Joe Christy on
$Date: 1997/09/09 14:11:16 $