Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing to a serial device server which does not support lpr 1

Status
Not open for further replies.

MWillo

IS-IT--Management
Jan 9, 2002
5
GB
I am trying to print to a Star TSP400 serial barcode printer via a lantronix UDS-10 serial device server. Lantronix support have told me that the UDS-10 does not support lpr or any of the other standard printing mechanisms, and the only way to send a job is via the ip address/tcp port combination.

After reading through other posts on similar subjects it seems that netcat may be the answer, but I'm slightly confused as to the way to use it.

The printing will be initiated via a script which strips out relevant information from a standard print file and adds the required control codes for the Star printer.

I realise this is a similar problem to others on network printing, but none of the articles I have read go into sufficient detail for me to solve the problem.

I would really appreciate any help

Regards

Mike
 
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
 
Thanks Tony,

It will be a few days before I'm back at this site to try this but, I can follow the process now. I'll let you know the outcome.

Thanks again for your help

Regards

Mike Willoughby
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top