1834019 Members
2970 Online
110063 Solutions
New Discussion

Printing to a File

 
SOLVED
Go to solution
George Abraham_1
Regular Advisor

Printing to a File

Hai All,

I want to create a Printer that will print to files in a Specific Directory. Say i have a Directory /test. when i give
#lp -dpr0 /etc/passwd. it should print to a file in the directory /test.

Can i do this through SAM?....

Thanks in Advance
George
keep smiling
5 REPLIES 5
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Printing to a File

Well, you can do part of this through SAM. Probably the easist thing to do is create a printer to a directly attached parallel or serial device using the 'dumb' interface. This doesn't have to be a 'real' printer, you just need to get the interface file written to /var/spool/lp/interface and the printer add will do that for you. You can them modify the interface file (it's just a shell script) to do whatever you like. You simply replace the section where the output is sent to a device node with a section of code that does your copy. You will probably need to add a section of code to generate a unique file name in your output directory.
If it ain't broke, I can fix that.
Sridhar Bhaskarla
Honored Contributor

Re: Printing to a File

Hi George,

Try this way.


touch /tmp/file_printer
chown lp:bin /tmp/file_printer
chmod 644 /tmp/file_printer
lpadmin -pmyfileprinter -v/tmp/file_printer -mlaserjet

lpshut
lpsched
enable myfileprinter
accept myfileprinter

lp -dmyfileprinter /etc/passwd

Verify it printed..

cat /tmp/file_printer

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Sajid_1
Honored Contributor

Re: Printing to a File

hello,

Create a virtual printer with:
# lpadmin -mprinter_name -vany_device_name -mdumb
# enbale printer
# accept printer

Now modify the printer script file under /etc/lp/interface and change the target (device_name) to the local file name
learn unix ..
Bill Thorsteinson
Honored Contributor

Re: Printing to a File

Create a new printer for output device /dev/null.
Create a filter script to output the file to your temp
directory with a unique name.

Extra points for the filter:
- Record meta info for the request (who, where, when).
- Clean out files older than x days.
- Limit space utilization in the directory.
- Set the file extension according to the file contents.
Helen French
Honored Contributor

Re: Printing to a File

George daa,

Did you solve the issue? I successfully tested the option which I told you on that day. Let me know if anything else ..

Sorry for answering late, but happy that you already got excellent answers.

later,
Shiju
Life is a promise, fulfill it!