A SERVICE OF

logo

Using the protocols
PagePrinter Network Adapter: Utilities & Environments 2-21
TCP/IP
networks
sss
#1 /bin/sh
module = $0
USAGE=”usage: $module [-b] f1 [f2..fn]”
HOST=”silver”
PRT=”/prt1” # overriding device default with prt1,
# change this to reflect the desired
# printer, or leave blank for default
USER=”printer”
if [ ”`echo $1 | fgrep ’7’`” |= ”” ] # give help if there is a 7 in parm 1
then
echo $USAGE
exit 1
fi
set -- `getopt b $*` # check for ’b’ as a command
if [ $? |= 0 ]
then
echo $USAGE
exit 1
fi
XFER=”ascii” # default transfer type is ASCII
for i in $*
do
case $i in
-b) XFER=”binary”,shift,, # changing transfer type to binary
--) shift,break,,
case
done
FileList=$*
PutCmds=’’
if [ -z “$FileList” ] # no files specified??
then
echo reading standard input 1 >&2
cat <&0 >/tmp/p$$ # put std input to a file
PutCmds=”put /tmp/p$$ SPRT
# this double quote ”MUST” be on this line
else
for i in $FileList # generate list of puts
do
FileName=$1
if [ -f $FileName ] # make sure the file exists
then
PutCmds=”${PutCmds}put $FileName $PRT
# this double quote ”MUST” be on this line
else
echo ”$module: file $FileName does not exist - cannot print”
fi
done
fi
ftp -n $HOST <<endofdata 1>/dev/null #startup FTP, passing parms on stdin
user $USER $pw
$XFER
$PutCmds
bye
endofdata
rm -f /tmp/p$$ >/dev/null 2>/dev/null # remove the file if it exists
exit