APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed
RSS Feeds RSS Feeds

(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Printer Friendly Version
-> (SCO Unix) How can I make a device that will print to a network printer?

SCO Unix/System V Printing FAQ

This article is from a FAQ concerning SCO operating systems. While some of the information may be applicable to any OS, or any Unix or Linux OS, it may be specific to SCO Xenix, Open Desktop or Openserver.

There is lots of Linux, Mac OS X and general Unix info elsewhere on this site: Search this site is the best way to find anything.

How can I make a SCO Unix/System V device that will print to a network printer?

First, are you really sure you need to do this? Only very lame software can't handle a spooled printer. However, if you must:

The basic concept is to create a named pipe. For example, you might do this:

mknod /dev/myfakenetprint p

That creates a "device" that your application can print to. Use "chmod" as necessary to give it whatever permissions you need (666 if everyone needs to use it).

Now you need something that runs all the time in background. It's a shell script (see New to Unix if you don't know how to make a shell script) and it needs to start automatically whenever the machine is rebooted (see Automating Program Startup). This script assumes that your network printer already exists in the spooler:

while true
cat /dev/myfakenetprint | lp -dmyrealnetprinter

Some folks have found that this works better in some places:

while :
exec </dev/myfakenetprint 
lp -dmyrealnetprinter

You could also use hpnpf or netcat (see Network Printing ) directly:

while :
cat /dev/myfakenetprint | netcat -h printername -p 3001


while :
exec </dev/myfakenetprint 
netcat -h printername -p 3001

These work because the "cat" will hang until something (your application) writes data to the named pipe. The "lp" won't complete until cat is done reading, which will be when your application closes its writing. Although it might look like this ties up your cpu, it doesn't- the cat sleeps while it hangs, and so does lp or netcat: there's nothing going on until you write data to the named pipe. If switching from a serial environment, you may find How can I assign a user process to a specific pseudo tty? useful also.

On a very busy system, it's possible for the writing process to send new data to the pipe before your reader process has sent it to the print server. You could implement a cooperative locking system to prevent that, but a small sleep at the end of the interface script will probably work.

You can use this same concept to implement "printers" that send email, queue faxes or do anything else you need done.

See Race conditions also.

If this page was useful to you, please help others find it:  


More Articles by - Find me on Google+

Click here to add your comments
- no registration needed!

Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments

If you want a picture to show with your comment, go get a Gravatar

Kerio Connect Mailserver

Kerio Samepage

Kerio Control Firewall

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

Jump to Comments

Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

I am a Kerio reseller. Articles here related to Kerio products reflect my honest opinion, but I do have an obvious interest in selling those products also.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.


This post tagged:

       - FAQ
       - Mail
       - Printing

My Troubleshooting E-Book will show you how to solve tough problems on Linux and Unix systems!

book graphic unix and linux troubleshooting guide

Buy Kerio from a dealer
who knows tech:
I sell and support

Kerio Connect Mail server, Control, Workspace and Operator licenses and subscription renewals

Click and enter your name and phone number to call me about Kerio® products right now (Flash required)