NERC Sysadmin Guide: Chapter 21: Useful Scripts
Here are a few useful tools we use from time to time.

Dumping to a remote tape device
Copying files with cpio
Copying files with uasm ( for Legato Networker users )
Copying files with ufsdump
Deleting files with names like -file
description of some useful UNIX commands which can be used to transfer large bundles of files across the network

Dumping to a remote tape device.

On the box you want to dump:

tar cvfb - 20 ~dfe/exec/g*.c | rsh tapehost dd of=/dev/rmt/0 obs=20b

To quiz the remote tape:

rsh -n tapehost dd if=/dev/rmt/0 ibs=20b | tar tvBfb - 20

On the box you want to restore to:

rsh -n tapehost dd if=/dev/rmt/0 ibs=20b | tar xvBfb - 20

Back to this page's Table of Contents

Copying files with cpio

cd /source/directory

find . -depth -print | cpio -pmud /destination/directory

Back to this page's Table of Contents

Copying files with uasm ( for Legato Networker users )
 

cd /source/directory

/path/to/uasm -s -i . | ( cd /destination/directory ; /path/to/uasm -r )

For Solaris Legato 5.2.1, uasm is found in /nerc/packages/networker/5.2.1/usr/lib/nsr/uasm on clients
and /usr/lib/nsr/uasm on the server.

For Irix Legato 5.2.1, uasm is found in /nerc/packages/networker/5.2.1/usr/etc/uasm

Both the cpio -pmud and uasm -r can be given a v option to make them chatty about what they are doing.

Back to this page's Table of Contents

Copying files with ufsdump
 

cd /source/directory

ufsdump 0f  file1 file2 directory1 wildcard | ( cd /destination/directory ; ufsrestore xf - )

Again, ufsrestore can be given a v option to make it chatty about what it is doing.

The ufsdump / ufsrestore technique will give you a relocatable version of the absolute path, as shown below.

amalfi# cd /etc
amalfi#
amalfi# ufsdump 0f - printers.* | ( cd /tmp/dfe ; ufsrestore xvf - )
Verify volume and initialize maps
  DUMP: Writing 32 Kilobyte records
  DUMP: Date of this level 0 dump: Tue Feb 20 13:48:50 2001
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c0t0d0s0 (amalfi:/) to standard output.
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Estimated 406 blocks (203KB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: 318 blocks (159KB) on 1 volume at 498 KB/sec
  DUMP: DUMP IS DONE
Dump   date: Tue Feb 20 13:48:50 2001
Dumped from: the epoch
Level 0 dump of a partial file system on amalfi:printers.conf
Label: none
Extract directories from tape
Initialize symbol table.
Make node ./etc
Extract requested files
extract file ./etc/printers.conf.25-Oct-2000.11:00:03
extract file ./etc/printers.conf.25-Oct-2000.10:51:46
extract file ./etc/printers.conf.25-Oct-2000.10:52:49
extract file ./etc/printers.conf
Add links
Set directory mode, owner, and times.
set owner/mode for '.'? [yn] y
amalfi#
amalfi# find /tmp/dfe -print
/tmp/dfe
/tmp/dfe/etc
/tmp/dfe/etc/printers.conf.25-Oct-2000.11:00:03
/tmp/dfe/etc/printers.conf.25-Oct-2000.10:51:46
/tmp/dfe/etc/printers.conf.25-Oct-2000.10:52:49
/tmp/dfe/etc/printers.conf
amalfi#

Back to this page's Table of Contents
 

Deleting files with names like -file

You cannot remove a name like -file as rm wiill parse the filename as an option string.  So, just use

rm -i ./-file

Alternatively, some versions of rm interpret - or -- as "end of arguments list" and a - thereafter is part of the file specification. man rm will give the "end of arguments" delimiter. For Solaris:

rm -i - -file

To remove a filename with a space, quote the filename

rm -i ' name'

The -i option makes it interactive, i.e. it will ask for confirmation before deleting.
It's safe enough just using rm without the -i above, but when experimenting it makes things safer if you are questioned about your intentions.

Back to this page's Table of Contents

This is a brief description of some useful, and very clever, UNIX commands which can be used to transfer large bundles of files across the network.

Definitions
~~~~~~~~~~

Source - the machine on which the original files reside
Target - the machine the files are to be sent to

tar up the desired directories and compress the output into file.Z

*1*  FTP to  Target machine from Source machine and "put" the file:
NOTE: for Alpha need to do ftp -p to allow the pipe symbol to be recognised.

   binary
   put "|tar -cf - ./v611 ./sas611 | compress " yourpipe.Z

Telnet to remote host

On the Target machine:

cd to directory where the install is to take place

Create a NAMED PIPE in the directory

   mknod yourpipe.Z p
   chmod a+r yourpipe.Z
   chown (susa, aptest ) pipe if not logging on as package
 

*2*       zcat yourpipe.Z | tar -xvpf -
On an SG *2*       zcat yourpipe.Z | tar -xvpBf -

This command begins reading from yourpipe.Z (which is being fed by ftp from other end ) with zcat. The output is piped through tar which unpacks the tar archive.
 

Note that 1 and 2 all run at the same time.
delete pipes when done:
rm yourpipe.Z ( at Target end)
 

in install server directory:

   find . -depth -print | cpio -oc > file.cpio
   ftp
   cpio -icdm < file.cpio

To ftp this:
On remote system:
------------------
   cd /local11/install-2.5
   mknod yourpipe p
   chown susa yourpipe
   chgrp ncs yourpipe
   cpio -icdm < yourpipe

and on local system:
-----------------------
   cd install-2.5
   ftp bsdbase.nbs
   binary
   put "|find . -print -depth |  cpio -oc " yourpipe

Back to this page's Table of Contents

Back to contents


This page last updated  February 20th 2001 by D.Feeley@itss.nerc.ac.uk