[comp.sys.next] quick & easy slip file transfers

mdixon@parc.xerox.com (Mike Dixon) (06/21/91)

here's a little hack i use to make slip file transfers as easy as
possible.  i put this csh script on the machine i log into at work,
with the name of my home machine ('sarah').  then, when logged in
over the slip connection, i can say things like

    sarah get foo >foo             (move a file from home to work)
    sarah print -2r <foo           (print a file from work at home)
    sarah get foo.ps | lpr         (print a ps file from home at work)

the script compresses things at one end and decompresses them at the
other to make the transfers as quick as possible.

there is also a general 'do' command, which is like rsh but
compresses the input stream (and should also compress the output
stream, i suppose).  there's also getu, putu, and dou, which
disable the compression (for files that are already compressed),
but they're not doing anything you couldn't do just as easily with
rcp and rsh.

the script refers to the machine it's run on as 'local', and the
machine it's connecting to as 'remote', but since you're actually
sitting at the 'remote' machine that could be a little confusing.

also, since i log in through an annex box my home machine doesn't
have a consistent network address; this script uses an environment
variable ('host') as the name of the remote machine (i set this
up in my cshrc file).  the first few lines just check that this
variable is set to something reasonable before proceeding.

------------------------------------------------------------
#!/bin/csh -f

set remote=$0
set remote=$remote:t

if (! $?host) set host=unknown
if ($host !~ termport*) then
   echo "I don't know where $remote is."
   exit 1
endif

if ($#argv > 0) then
switch ($1)

case put:
   if ($#argv != 2) then
      echo "syntax: $remote put $remote-file-name <local-file-file"
      exit 1
   endif
   compress | rsh $host "uncompress >$2"
   exit

case putu:
   if ($#argv != 2) then
      echo "syntax: $remote putu $remote-file-name <local-file-file"
      exit 1
   endif
   rsh $host "cat >$2"
   exit

case print:
   compress | rsh $host "uncompress | enscript $argv[2-]"
   exit

case do:
   if ($#argv == 1) then
      echo "syntax: $remote do arbitrary-command ...
      exit 1
   endif
   compress | rsh $host "uncompress | $argv[2-]"
   exit

case dou:
   if ($#argv == 1) then
      echo "syntax: $remote dou arbitrary-command ...
      exit 1
   endif
   rsh $host "$argv[2-]"
   exit

case get:
   if ($#argv != 2) then
      echo "syntax: $remote get $remote-file-name >local-file-file"
      exit 1
   endif
   rsh $host "compress <$2" | uncompress
   exit

case getu:
   if ($#argv != 2) then
      echo "syntax: $remote getu $remote-file-name <local-file-file"
      exit 1
   endif
   rsh $host "cat $2"
   exit

endsw
endif

echo "options:\
    $remote put $remote-file-name <local-file-file\
    $remote get $remote-file-name >local-file-name\
    $remote do <local-file-name\
    $remote print [options...] <local-file-name\
        (e.g. $remote print -2r <my_file)\
(also, putu, getu, and dou can be used to disable compressed transfers)"
exit 1

------------------------------------------------------------
--

                                             .mike.