	Unix shell script that provides Unix systems lp printer access to the GPS 	printers defined in CTOS via FTP.  Procedure for installing a phantom lp 
	printer on your Unix system are contained below.

	As this script runs, it builds a control file and additional scripts
	to handle the FTP transfer of the control file and the lp printed output 
	to the CTOS system.  The RemoteGPS CTOS system service then takes the 
	printer files defined by the control file and processes them into GPS. 

	There are a few simple changes that must be made to this script before you 
	add the new lp printer.

	1.	Replace CTOS in the remote_host=CTOS statement below with the name
		of the CTOS system where the RemoteGPS server is or will be running.

remote_host=CTOS

	2.	You might change image to ASCII below, but only if your're only 
		sending ASCII text files that contain carriagereturnlinefeed line
		ending characters that must be changed to linefeed only.
		Otherwise, leave it alone.

remote_type=image

	3.	Provide values for remote_login and remote_password.

	NOTE:	Depending upon the version of Unix you are using, there are 2 ways 
			this script can handle the login to ftp.
			
			If the remote_login and remote_password variables are left null,
			i.e., remote_login= and remote_password=, this script will 
			rely on a .netrc file in the home directory.

			If you provide values for remote_login and remote_password, the 
			script will build them into the FTP scripts and you will not need 
			a .netrc file.


remote_login=
remote_password=

			Unix operating systems derived from the Berkeley releases must use
			the .netrc method for FTP login because they will not accept a 
			password from a shell script.  To insure that .netrc is used, make 			sure that the remote_login and remote_password variables below 
			remain NUL ().

			If needed, the .netrc file should contain:

			machine remote_host
			login remote_login
			password remote_password

			where:	remote_host		is the name of the CTOS system running 
									RemoteGPS.
					remote_login	is the login name to be used to transfer 
									the files.
					remote_password	is the password associated with that login
									account.

			The permissions of the .netrc file should be rwx
			The command chmod 700 .netrc will accomplish this.


	4.	FTP this file to the Unix system.  It can be placed in your home 
		directory or any other convenient place.  During the installation of 
		the new lp printer below the script is copied by lpadmin into 
		usrspoollpinterface.

	5.	Create a usrspoollpctos directory.

		mkdir usrspoollpctos

	6.	Set the permissions and ownership for the ctos directory.

		chmod +wr usrspoollpctos
		chown lp usrspoollpctos
		chgrp bin usrspoollpctos

	7.	Shut down the lp scheduler.

		usrliblpshut

	8.	Add the new printer.  The following command assumes your are in the 
		directory that contains the remotegps.sh script you transferred with 
		FTP.

		usrliblpadmin premotegps l vdevnull iremotegps.sh

	9.	Start up the lp scheduler again.

		usrliblpsched

  10.	Tell the lp scheduler to accept output for remotegps.

		usrlibaccept remotegps

  11.	Enable remotegps.

		usrbinenable remotegps

  12.	Check out the lp system status.

		usrbinlpstat t

==============================================================================

	The following is a standard unix lp command.  It is shown here to give an
	example of how the parameters generated by the command are interpreted by 	this script.  Depending on your default lp printer assignment in Unix and 
	the need for the optional parameters, it may be possible to print using 
	just:  lp filename.

	lp dremotegps n2 o'2 hplaser' t'This is the title' file1 file2

	PARMAETER	VALUE					MEANING

	interface	interfaceremotegps		interfaceprintername
	job			remotegpsxxxx			where xxxx is a unique number for 
										remotegps. This parameter is generated 
										by lp.
	owner		?????					login user name for person using lp 
										command.  Also generated by lp.
	title		This is the title		t option
	copies		2						n option
	options		2 hplaser				o option
										It must be 0, 1, 2, 3, 4  andor 
										contain the name of a different GPS 
										device then the one with which the 
										RemoteGPS server was installed. 

	files		file1 file2				files to be printed

==============================================================================

interface=$0
job=$1
owner=$2
title=$3
copies=$4
options=$5
shift; shift; shift; shift; shift
files=$*

	printer		= remotegps

printer=basename $interface

	host		= (output of hostname command)

host=hostname

	job			= xxxx (strip remotegps from job)

job=echo $job | sed s$printerg

	cleanup directory

rm f usrspoollpctos*

	now create script and execute ftp once for each file

for file in $files
do

	base	= file name without directory

	base=basename $file

	base	= remove the xxxx from base

	base=echo $base | sed s$jobg

	copy the file to the ctos directory

	cp $file usrspoollpctos$base

	copy the file to the ctos directory

	create ftp script file (see above notice about ftp login)

	echo open $remote_host >> usrspoollpctosftp
	if [ n $remote_login ]
	then
		echo user $remote_login >> usrspoollpctosftp
	fi
	if [ n $remote_password ]
	then
		echo pass $remote_password >> usrspoollpctosftp
	fi
	echo type $remote_type >> usrspoollpctosftp

	name the file remotegps_xxxx_$base on the CTOSBTOS system

	echo put usrspoollpctos$base $printer\_$job\_$base >> usrspoollpctosftp
	echo bye >> usrspoollpctosftp

	usrlocalbinftp < usrspoollpctosftp > devnull

	rm f usrspoollpctos*

done

	write out params file

echo :Host:$host >> usrspoollpctosparams
echo :Printer:$printer >> usrspoollpctosparams
echo :Job:$job >> usrspoollpctosparams
echo :Owner:$owner >> usrspoollpctosparams
echo :Title:$title >> usrspoollpctosparams
echo :Copies:$copies >> usrspoollpctosparams

	Checkout options ( 0, 1, 2, 3, and 4 are mode, otherwise gps device name

for opt in $options
do
	case $opt in
		0) echo :Mode:0 >> usrspoollpctosparams ;;
		1) echo :Mode:1 >> usrspoollpctosparams ;;
		2) echo :Mode:2 >> usrspoollpctosparams ;;
		3) echo :Mode:3 >> usrspoollpctosparams ;;
		4) echo :Mode:4 >> usrspoollpctosparams ;;
		*) echo :Device:$opt >> usrspoollpctosparams ;;
	esac
done

	1 line for each file

for file in $files
do
	base=basename $file
	base=echo $base | sed s$jobg
	echo :File:$base >> usrspoollpctosparams
done

	done with params file output

	now create ftp script file


echo open $remote_host >> usrspoollpctosftp
if [ n $remote_login ]
then
	echo user $remote_login >> usrspoollpctosftp
fi
if [ n $remote_password ]
then
	echo pass $remote_password >> usrspoollpctosftp
fi
echo type $remote_type >> usrspoollpctosftp

	name the params file remotegps_xxxx_params on the CTOSBTOS system

echo put usrspoollpctosparams $printer\_$job\_params >> usrspoollpctosftp
echo bye >> usrspoollpctosftp

	execute the ftp client with input from script and output tossed

usrlocalbinftp < usrspoollpctosftp > devnull

	cleanup directory

rm f usrspoollpctos*

exit 0
