Operating System - HP-UX
1846658 Members
3606 Online
110256 Solutions
New Discussion

LP Command Script Writing Sequential Number on Spool File

 
Son Le_1
Occasional Advisor

LP Command Script Writing Sequential Number on Spool File

Hello. I am trying to figure out how do I use the lp command to print to a file that names it for example, sp1.spl, sp2.spl, sp3.spl, sp4.spl, etc...and put it into a directory (/printer/spool). Any help is appreciated. Thanks.
11 REPLIES 11
Pete Randall
Outstanding Contributor

Re: LP Command Script Writing Sequential Number on Spool File

As you've stated the problem, the answer would be

cp sp?.spl /printer/spool
for i in /printer/spool/*
do
lp /printer/spool/$i
done

I'm sure that's more simplistic than you intended. Could you expand on your requirements?


Pete

Pete
Son Le_1
Occasional Advisor

Re: LP Command Script Writing Sequential Number on Spool File

I have a software in HP-UX 11.0 that uses a printer open command. The thing I am trying to do is when I print something in this software that it spools to a file and start naming it sequential after that. As of right now, when I print something to file, it goes to a file called, file.prt. This however gets overwritten each time I print to file. That is why I am trying to use the lp command to print to file so that if I do multiple print, that it doesn't get overwritten. Thanks for your help.
Pete Randall
Outstanding Contributor

Re: LP Command Script Writing Sequential Number on Spool File

So, is this software that uses a "printer open command" a compiled program or a shell script?


Pete

Pete
Son Le_1
Occasional Advisor

Re: LP Command Script Writing Sequential Number on Spool File

its a compile program...its called Eldorado. It is programmed in dbc. If i enter in lp -dis2 -olandscape in the open command field, it will print whatever I request to the printer IS2.
Pete Randall
Outstanding Contributor

Re: LP Command Script Writing Sequential Number on Spool File

Sorry, I can't think of a way to change the behaviour of a compiled program when you have such limited input to it.


Pete

Pete
Son Le_1
Occasional Advisor

Re: LP Command Script Writing Sequential Number on Spool File

I tried the lp /print/spool/$i and it didn't work. The printer open command is just something that I can either put in a lp command in or any command actually that you can do in unix. What is the command to output something to a file, i know you use ">>" without the quotation to output something.
Rodney Hills
Honored Contributor

Re: LP Command Script Writing Sequential Number on Spool File

Modify the print driver script (if you are using "lp" command, then you can find it at
/usr/spool/lp/interface/model.orig/printer)

You can add code to redirect the output to a file here.

HTH

-- Rod Hills
There be dragons...
Son Le_1
Occasional Advisor

Re: LP Command Script Writing Sequential Number on Spool File

there are a lot of codes in there....what exactly do I have to write in there. Thanks.
Rodney Hills
Honored Contributor

Re: LP Command Script Writing Sequential Number on Spool File

If this print queue is not to an actual printer. You can delete most all the code in the driver and place what you want in it. Keep the code up to where variable "files" is set.

I incorrectly told you the wrong driver file, it is /usr/spool/lp/interface/printer.

You may want to brush up on your shell script programming.

-- Rod Hills
There be dragons...
Bill Hassell
Honored Contributor

Re: LP Command Script Writing Sequential Number on Spool File

Use the 'dumb' model script as a start. What you need to create is a printer script that does not actually print but instead, directs the output to a file. Printer scripts are a bit complex if you haven't done much scripting before. Your script will be given several command line options, then you would create the appropriate filename. NOTE: the printer script is run only when you run the program so it has no memory of previously created files. The script would have to look at the files already created and pick the next name. The name of the print file created by your program will be on the command line, you just cat that file and redirect it into your directory with sp1.spl, sp2.spl, sp3.spl, etc.

Once the script is working locally, you would add it to the spooler using lpadmin. The output printer device will be /dev/null.


Bill Hassell, sysadmin
Son Le_1
Occasional Advisor

Re: LP Command Script Writing Sequential Number on Spool File

i was hoping I didn't have to program anything but I guess thats my only option. Thanks for the effort.