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 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 printer that will print to a file?

For CUPS (Linux. Mac) printing, see CUPS (Common Unix Printing System) print to file - the hard way!

SCO (without CUPS): Setting up a printer that will print to a file can be useful for any number of reasons. Here we set up two printers; one that prints to files in the user's home directory, and another that prints to a shared common area.

The first problem is that we need a root process to do the writing. We could do that with sudo or asroot (SCO), but I chose to do it with two scripts that read named pipes. These scripts are run at startup:

 
 
 # cat /usr/bin/startshared
 mknod /dev/sharedprint p
 chmod 777 /dev/sharedprint
 while true
 do
 cat /dev/sharedprint | /usr/local/bin/sharedprint
 done
 
 # cat /usr/bin/startpersonal
 mknod /dev/persprint p
 chmod 777 /dev/persprint
 while true
 do
 cat /dev/persprint | /usr/local/bin/persprint
 done
 

The printers will send their data to the appropriate devices, and in turn the data will be passed to the scripts that actually do the writing. We've modified the printer scripts to send the user name as the first line of the data:

 
 # cat /usr/local/bin/persprint
 read user
 cd /usr/$user || cd /
 if [ ! -d PRINTED ]
 then
   /bin/mkdir PRINTED
   /bin/chown $user PRINTED
   /bin/chmod 755 PRINTED
 fi
 cd PRINTED
 DATE=`/bin/date +%y%m%d%H%M%S`
 /bin/touch $DATE
 /bin/chown $user $DATE
 while read stuff
 do
 echo $stuff
 done > $DATE
 /bin/chmod 664 $DATE
 

This was on a SCO system, with user home directories in /usr; we could make a more complex script that would extract the home directory from /etc/passwd. The file name is just a simple date stamp. For the shared printer, we include the user name:

 
 # cat  /usr/local/bin/sharedprint
 read user
 cd /usr/shared/FORMS
 if [ ! -d PRINTED ]
 then
   /bin/mkdir PRINTED
   /bin/chown $user PRINTED
   /bin/chmod 755 PRINTED
 fi
 cd PRINTED
 DATE=`/bin/date +%y%m%d%H%M%S`
 DATE=$user.$DATE
 /bin/touch $DATE
 /bin/chown $user $DATE
 while read stuff
 do
 echo $stuff
 done > $DATE
 /bin/chmod 666 $DATE
 

The printer needs to send us user information. In this case, we modified a copy of SCO's "dumb" interface script:

 # diff dumb personal
 44c44
 < nobanner="no"
 ---
 > nobanner="yes"
 61a62
 > user=`grep "^$2:" /etc/passwd | line | cut -d: -f1`
 91c92
 < echo "\014\c"
 ---
 > echo "$user"
 100d100
 <               echo "\014\c"
 

but we could also have just written a more complex parsing that could have extracted this from banner pages.

I added the printers like this:

 /usr/lib/lpadmin -p personal -m personal -v /dev/persprint
 /usr/lib/accept personal
 enable personal 
 

These same concepts will work with Linux or any other Unix-like OS. The only real requirement is that the print job include user info, and even that isn't necessary if you only want the shared version. Just point the printer at the named pipe instead of /dev/lp0 or anywhere else.

See also SCO TA #110966



Got something to add? Send me email.





(OLDER) <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

->
-> (SCO Unix) How do I make a printer that will print to a file?

4 comments



Increase ad revenue 50-250% with Ezoic


More Articles by

Find me on Google+

© Tony Lawrence







Tue Jul 5 09:06:07 2005: 750   anonymous


Hi

Found this at Sco Support at this URL
(link)
It looks like a simple solution.

(b) Another method to print to a file is as follows:
As "root", create a file, for example "/myprintfile":


# cat >myprintfile
# ls -al myprintfile
-rw-r--r-- 1 root sys 0 Apr 10 09:17 myprintfile


Change its owner and group permissions to "lp":

# chown lp:lp myprintfile
# ls -al myprintfile
-rw-r--r-- 1 lp lp 0 Apr 10 09:17 myprintfile


As in (a) above, start SCOadmin and create a local printer, with the following parameters:

Name: fileprint
Description: Print to file
Model: Standard
Device: /myprintfile


Check that it is set up:

# lpstat -a
...
fileprint accepting requests since 09:24:15 AM Mon 10 Apr 2


Print a file:

# lp -d fileprint /etc/motd
request id is fileprint-546 (1 file)


The file prints into the file "myprintfile" including its banner page. Subsequent prints are appended to the file.
The configuration file with the "/myprintfile" device can be seen in the file "/var/spool/lp/admins/lp/printers/fileprint/ configuration".







Thu Jul 10 18:01:59 2008: 4411   anonymous


For some reason, after each print process, a zombie stays hanging around. Any ideas?



Thu Jul 10 18:19:39 2008: 4412   TonyLawrence

gravatar
Be specific. Exactly what are you seeing?



Thu Jul 10 20:50:32 2008: 4413   anonymous


Hard to say at the moment; after "printing" to file using your suggestion, I see one more "Defunct" process in the list of processes. No idea what that process was, though, it just reads "Defunct".

------------------------
Kerio Samepage


Have you tried Searching this 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.

Contact us