[comp.unix.shell] transferring multiple files via cu

michaelp@dadla.WR.TEK.COM (Michael Prusynski) (10/18/90)

In a previous article sean@utoday.UUCP (Sean Fulton) writes:

>We use a shell script and UUCP to do an automated ascii upload to a
>publishing system that is pretty void of any knowledge of
>communications with the outside world.

>At any rate, we have a /bin/sh script that basically does:
>	cu sysname <FILE
>Where FILE is of the form:
>
>~!/bin/slp10 	 			#wait 10 seconds
>piles of data to be uploaded
>~!/bin/slp10				#wait another 10 seconds
>~.					#Hangup the telephone.

>This has been somewhat reliable, but only allows for one file
>per call. Given that there is a modem shortage on the remote end, this
>is unacceptable.

>So, does anyone have any ideas on how to do something like:
>
>~!for a in `ls files`
>... etc.


If the remote system is a Unix system with tar you can save the output
of tar in a file via:  tar -cvf outputfile sourcepath
Then transfer it and untar it on the remote system, which preserves the
dates of the files.  Sounds simple, BUT THERE IS A COMPLICATION:
because "outputfile" contains NULLs, in order to transfer it with cu,
you have to ASCIIfy it (preferably with uuencode), then transfer it,
unASCIIfy it (uudecode), then untar it.
The computers must have tar and uuen/decode, and you have to remember
how to use them, and remember to remove the uu and tar files.
Here is my "tar+encode" shell script to try to keep it all rememberable.
---------- cut here ----------
: 'This program uses tar to transfer more than one file to remote host via cu
: It tars up a directory of files and then uuencodes them because tarfiles
: contain NULLs and will not transfer via cu  (Michael Prusynski - Sep. 1990)'
PATH=/bin:$PATH

case $1 in
	"") echo "usage:  $0 {source_path} [dest_path] "; exit 1;;
esac
dest=$$
case $2 in
	"") ;;
	*) dest=$2 ;;
esac
sh -cx "tar -cvf $dest.tar $1"
sh -cx "uuencode $dest.tar $dest.tar > $dest.uu"
echo "
file: $dest.uu is ready for transfer to remote host.
When transfer is done, type:  uudecode $dest.uu
                  then type:  tar -xvf $dest.tar
Remove $dest.tar and $dest.uu on both hosts when done."