If this still confuses you, try to tell me where you get lost and I'll try to fix it
Where do I get "netcat" and how do I use it?
(I want to thank Jack Wendel for many suggestions that hopefully have made this section easier to understand)
The netcat we are talking about here can be found at
There is another more widely known netcat ("nc"

written by Hobbit that is used (among other things) for port scanning.
Netcat "cats" to the network. Most network printers work that way at some port number. For example, HP printers use port 9100. So if you open up port 9100 (a simple "telnet deviceip 9100" is all it takes), anything that is presented there will be printed. So with netcat, all you need is a hostname or a raw ip address and the proper port number. Anything you send will be printed- it's that simple. Just like you "cat" a file to the screen, "netcat" sends it to an ipaddress and a port (though unlike "cat", netcat is a filter- you pipe data TO it).
Why use netcat? Because it works. Time after time I've fixed nasty and confusing network printer problems by just using netcat instead of the HP printing method or even lpd. Netcat works.
Download netcat from the link above or, if you don't want the C program source and don't need a COFF binary, use this ELF binary (if you don't understand any of that, you probably want the ELF):
.
Copy that to /usr/bin/netcat or anywhere else you like (somewhere in your PATH is a good idea).
A simple netcat interface script is:
PORT=9100 # for hp, netgear, some others
shift; shift; shift; shift; shift
# The lpsched program sends 5 arguments that we are going to ignore.
# arguments 6 and on are the file names to be printed
# We just throw away everything but the file names by using shift 5 times
# arguments 6 through whatever are now $*
cat $* | netcat -h printserver -p $PORT
You'd save that as "netcat" in /usr/spool/lp/model. When you create your printer, use that as the interface script (it will appear in your list of choices). What I do is copy it to the name I will use for the printer, modify the copy to use the correct host name or ip address and port number, and then my printers use the same name for their scripts: printer "officehp" uses the interface script "officehp" etc.
You don't have to use the printer configuration manager to add a simple printer. For example, to add a printer called "printer" after modifying the script as above:
/usr/lib/lpadmin -p printer -m netcat -v /dev/null
# MUST have /usr/spool/lp/model/netcat script !!
# If script were called "hpprinter" you'd do:
# /usr/lib/lpadmin -p printer -m hpprinter -v /dev/null
# then:
/usr/lib/accept printer
enable printer
Here's another example that uses an ip address on an Intel Netport port 2:
PORT=3002
shift; shift; shift; shift; shift
cat $* | netcat -h 192.168.2.9 -p $PORT
And here's a Netgear PS110 on port one:
shift; shift; shift; shift; shift
cat $* | netcat -h netgear.wherever.com -p 4010
Remember, these are interface scripts you will use when you define a printer.
If your application lets you specify a printer command (RealWorld, Mas90/Mas200 and many more), you can use netcat directly. For example, you might have previously put something like this in a configuration file:
LP1=">lp -dmyprinter %s";export LP1
(This is the way Realworld configures printers; it's not necessary for you to understand this)
You'd replace this with:
LP1=">netcat -h printerip -p 9100";export LP1
If the "printerip" is the address you can "ping" and 9100 is the port number used for printing.
There are other examples here. These are more complex examples that may require some experience to use and understand.
Printing through pipe device
Printing through interface script
You'll also want to see
to find out what port numbers to use with your network printer or printserver. IF YOU USE THE WRONG PORT NUMBER IT WON'T WORK.
Tony Lawrence
SCO Unix/Linux Resources
tony@pcunix.com