1835021 Members
2422 Online
110073 Solutions
New Discussion

printer script

 
SOLVED
Go to solution
John Flanagan
Regular Advisor

printer script

I have configured some NT pc with winnt lps and set them for pass thorugh printing. I have modified the printer scripts to add come control codes for font ptich etc.

Is it possible to take an existing print script such as that for a laserjet 4 and get it to send it's output to the remote printer.

Thanks in advance,

John.
9 REPLIES 9
Bill Hassell
Honored Contributor

Re: printer script

If you mean: print from HP-UX to the NT box, the answer is yes but with caveats. None of the -o options to lp will work as NT does not understand SysV print spooler options. Also, plain ASCII files will be sent as they appear on the disk (text-LF-text-LF...) which is printed exactly in that manner, stairstepping down the page. You'll have to fix the NT side to add CR to each ASCII file LF character.

Othwewise, you'll have to add the CR before you print using: ux2dos file-to-print | lp ...

Add the printer using SAM and the remote printer menu.


Bill Hassell, sysadmin
Leif Halvarsson_2
Honored Contributor

Re: printer script

Hi
If I understand you right you want to set up a remote printer on a HP-UX client to a printer on a Windows system.

It is possible, but it is a job for a "hacker".

Create a remote printer on the HP-UX client. Now you have got a interface script in /var/spool/lp/interface.

Take a copy of the standard laserjet 4 interface script.

This two scripts must be "merged" so the print processing is done on the local system to a temporary file and this preprocessed file is sent to the remote printer instead of the original file.

When printing to a remote UNIX printer the print processing normaly is done remote.
John Flanagan
Regular Advisor

Re: printer script

Leif, That is exactly what i want to do. As far as I can make out the stty statement is used to capture standard output and send it directly to the printer.

Is it easy to change this to send it all to a file say $1.tmp.

Regards,

John.
Olav Baadsvik
Esteemed Contributor

Re: printer script



Hi,

Just enclose the part of the script
that contains echo and cat in
( ) > unique_file_name

and everything that otherwise would have
gone to the printer now goes to unique_file_name.
Normally you would use the PID as part
of the file name. Ex /tmp/$$file_name

Olav
Jordan Bean
Honored Contributor

Re: printer script

Hey John,

You're in luck. I'm doing what you want to do with the attached interface script. However, my remote printers are no going through Windows servers, but rather directly to network attached printers. So I don't know for sure if this will work for you.

Study it carefully. It does all its work in the printer's spool directory (/var/spool/lp/request/). It uses the PCL5 model script to format the print job (if required) before giving it to rlp.

You must make sure the model scripts you will use are executable or the script will fail, disable the queue, and bitch about it via email to the lp admin. So do this:

chmod 555 /usr/lib/lp/model/PCL*

To setup the printers, just create remote printers like you normally would. Then replace the interface script in /etc/lp/interface with this script.

Leif Halvarsson_2
Honored Contributor
Solution

Re: printer script

Hi

I had a look at the laserjet4 model script in /var/opt/lp/model. It is rather complex but not difficult to understand. The script "echo" a lot of escape seqences and then finaly "cat" the file. This means evrything (with the exceptin of errors) is written to stdout. The stty commands is for serial ports, in your case you should remove them.

Some ideas:

Define a "modified" version (without stty) of the laserjet4 model interface script as a function in the main interface script.

Call this function with the nessesary parameters from the main script and redirect the output from this function to a temporary file.

Send this temporary file to the remote printer with rlp.

This need some work and it is not simple but it is not impossible.

John Flanagan
Regular Advisor

Re: printer script

I have almost got my problem solved. My poor knowledge of shell scripts has caused some delay.

My script will now process the file correctly and every thing seems to work correctly as far as the 'rlp' line. When the file that should be going to the printer is called 'dfA123ptihp1.job' I will get an error in '/var/adm/lp/log' stating that 'cfA123ptihp1.job' can not be found.
John Flanagan
Regular Advisor

Re: printer script

Problem solved. Thanks everybody for the help. My script is attached if it is of any use to anyone.
John Flanagan
Regular Advisor

Re: printer script

Sorry. correct version.