start page | rating of books | rating of authors | reviews | copyrights

Unix Power ToolsUnix Power ToolsSearch this book

38.8. Using GNU tar with a Remote Tape Drive

If you're using GNU tar, you can probably ignore the tips in Section 38.7 about using a tape drive on a remote system. GNU tar makes it easy to access a remote drive via rsh or a similar command like ssh.

When referring to a local host, the GNU tar f option takes a plain filename like foo.tar or a device name like /dev/rmt0. If you put a colon (:) before that name, though, you can prepend a remote hostname -- and, optionally, a username. For example, to get a table of contents of the tape on the drive /dev/rmt8 on the remote host server2, logging into server2 as yourself, type:

% tar tf server2:/dev/rmt8

To specify a different username than the one on your local host, add it with an @ before the hostname. (This assumes you're allowed to connect to the remote host without a password -- because there's a .rhosts file on the remote system, for instance.) For example, to connect to server2 as heather and extract the files reports/products.sgml and reports/services.sgml from /dev/rmt8:

{ } Section 28.4

% tar xf
heather@server2:/dev/rmt8 reports/{products,services}.sgml

By default, GNU tar uses rsh, remsh, or nsh to access the remote machine, though that can be changed when tar is built and installed on your host. If you want another access command, like ssh, you can set that with the - -rsh-command option. The next example gets the contents of the archive on the drive /dev/rmt8 from the host capannole.it using ssh. Note that tar doesn't check your search path (Section 27.6) for the rsh-command; you have to give its absolute pathname (which you can get with a command like which (Section 2.6)):

% tar -x --file=capannole.it:/dev/rmt8
--rsh-command=/usr/bin/ssh

On the other hand, if you need to use a local filename with a colon in it, add the - -force-local option.

-- JP



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.