Using a Netcom II Virtual Circuit to operate a remote printer in the SCO OpenServer 5 environment

Overview
There's as many different ways to use remote printers as there are remote printers to use. This application note describes two of these – one, using the cu command of UNIX, and the other using the /usr/lib/x25/utils/xprint command supplied with Netcom II. Both of these commands send print files over an X.25 Switched Virtual Circuit to a remote PAD which has a serial printer connected to one port on the PAD.

Next, we describe how to receive a stream of data on a UNIX system with Netcom II to output to the line printer system.


Using cu
There's really two steps involved in doing what you want. First, making sure you can get to the printer via cu, then integrating the printer with the spooler.

For step 1, you need to make some changes to a few files. Here they are:

In /usr/lib/uucp/Dialers, add a line:
tsg "" "" \r Command\n\r C\D

In /usr/lib/uucp/Devices, add a line:
x250 x250/X0020 - Any tsg \D

In /usr/lib/uucp/Systems, add a line:
rpad Any x250 Any ia9999999

Replace the `9999999' with the Datapac address of your PAD.

To test that this all works, you should be able to do `cu rpad', wait for connection, then you should see whatever you type on your UNIX session on the printer.

Once you're at that point, you just need to integrate it with the printer spooling system. To do that, use:

/usr/lib/lpadmin -premoteprint -Urpad
enable remoteprint
accept remoteprint

Then, you should be able to do things like `ls -l | lp -d remoteprint', and have the result print out on the printer.

In the example above, we've assumed that the PAD you're using is one which allows you to configure which serial port is to be connected to an incoming call. Some PADs require that you select a port by supplying a particular byte (or string of bytes) in the Call User Data associated with the call. If that's the case, you have to modify your call script line in /usr/lib/uucp/Systems to specify Call User Data as well as the remote address. For example, if your PAD uses an ASCII `a' to select a serial port, use:
     rpad Any x250 Any ia9999999cuda

In the example above, the string `cuda' indicates that you want Netcom to put an `a' as the first byte of Call User Data following the protocol selection field.


Using xprint
We supply a utility program, xprint, to do the same thing as described above. It uses the Netcom II API, so any problems introduced by tty line disciplines and interaction with the X.25 network (like flow control) won't occur. However, it's a bit more difficult to set up, because it involves making some manual changes to the printer spooling system.

xprint uses the same command line syntax as talkt and xpad. However, once it has connected a call, it simply sends everything it receives as stdin down the X.25 link to the remote device, which it assumes is either a PAD, or a process collecting information to send to a remote device (if the remote device is another Netcom machine).

To test xprint, replace the 999999 in the following example with the address of the remote device connected to the printer, and enter it as a command line:
     ls -l | xprint -d 9999999

Once you've been able to get a listing of the contents of your directory on the printer (make sure that you do it in a directory that contains files !), you can integrate it with the UNIX printer spooling system.

To do this, run lpadmin to make your new printer:

/usr/lib/lpadmin -premoteprint -i/usr/spool/lp/model/network -v/dev/null
enable remoteprint
accept remoteprint

If you're running on a SCO system, /usr/spool/lp/model will have a script called network, and, after installing the printer, you edit /usr/spool/lp/remote to contain the line:
     remoteprint: /usr/lib/x25/utils/xprint -d 999999999 -ua

You'd actually replace 99999999 with the network address of your PAD, and `-ua' is only required if your PAD doesn't always connect incoming calls to the same serial port each time it's called.

Again on SCO, you also have to edit the file /usr/spool/lp/admins/lp/interfaces/remoteprint. Edit the last line of this file to read:
     ) | $network

That is, delete the arguments you'll see following the $network command.

If you're not running on a SCO system, it's a bit more complex. Don't use `-i network' option. When you omit this, lpadmin uses the default interface script. After lpadmin finishes, you have to manually change the interface script for the printer you installed by editing /usr/spool/lp/admins/lp/interfaces/remoteprintto use xprint instead of cat or lpcat to print the file.

Receiving into the lp system
If you set up one end of the X.25 virtual circuit with cu as described above, then you can set up a cat | lp on the incoming call on a receiving Netcom II, as follows:

In /etc/x25tab, add a line like this: CUD=\1\0\0\0a:ACCEPT:X29:YES:/bin/sh /etc/sh_pr

Again, Call User Data of "a" is used here to distinguish the printer data from other calls. Different Call User Data may be more appropriate for you.

Next, create the shell script /etc/sh_pr with:

:
stty -echo
cat - | lpr