Operating System - HP-UX
1755629 Members
3920 Online
108836 Solutions
New Discussion юеВ

Re: Problem on printer interface

 
Colin_4
Occasional Contributor

Problem on printer interface

I created a virtual printer in HP-UX. If I manually run the printer's interface script, the script works fine. I can get the printout. But when I trigger it by lp -d 'virtual-printer-name' ..., one of the program in the printer interface doesn't work properly and return a non-zero error back to lpsched and makes itself being disabled. I have checked the program's permission and environment setup running in the interface. Everything seems fine. Becuase I don't have too much knowledge on the mechanism of printer interface, can anybody tell me the difference between running the interface under shell and running by lpsched.

Thanks very much for any suggestion.

Colin
6 REPLIES 6
A. Clay Stephenson
Acclaimed Contributor

Re: Problem on printer interface

Hi Colin:

Since your interfacxe script works when you execute from the shell, you are very close.
I suspect that your are calling some programs that are not in the PATH when lp runs it. simply place some staements something like this early in in your interface;
PATH=/usr/sbin:/bin:/usr/bin:/usr/local/bin
export PATH
Just make sure that all the utilities called within your interface are covered. The other thing is to make sure that your interface script and anything el;se that it calls is executable by user 'lp'. Your interface should have 755 permissions; owner lp; group bin.

Clay
If it ain't broke, I can fix that.
Wodisch
Honored Contributor

Re: Problem on printer interface

Hello,

could it be that you use some interactive command (like "stty") somewhere?
That would not work when called from "lp"...

HTH,
Wodisch
A. Clay Stephenson
Acclaimed Contributor

Re: Problem on printer interface

Hi Colin:

One more thing that can get is not understanding the argument convention for an iterface file. You must follow it EXACTLY.

0)The interface file in /var/spool/lp/interface must be named the same as your printqueue name.

1) Arg 1 ==> Printer Request ID
2) Arg 2 ==> User (Logname of user who made the lp request)
3) Arg 3 ==> Title (may simply be "")
4) Arg 4 ==> Number of Copies
5) Arg 5 ==> the -o options (all of them are quoted within arg5)
Arg 6, .... full path name(s) of the file(s) to be printed

Note that your interface may want to do something with the first 5 arguments but in must then do a shift 5 to get to the filenames.

Clay
If it ain't broke, I can fix that.
Colin_4
Occasional Contributor

Re: Problem on printer interface

Hi Clay and Wodisch,

Thanks very much for your help.

After reading your replies, I double checked all the points you mentioned. The permission for the virtual printer interface and the programs running in the scripts should all be correct. The interface script is 755 and lp:bin. The programs inside the interface are all 777. The six arguments you mentioned in your last notice are set properly in the interface. Also, full path is being used in the interface to run all program.

I know which program in the interface is causing the problem. That program's permission is also being set to 777 and it's called in full path name. I don't know why it works in the interface when I run the script on shell, but stops and returns error when it's run by the lpsched.

Thanks again for your guys help

Colin
A. Clay Stephenson
Acclaimed Contributor

Re: Problem on printer interface

Okay Colin:

One of the other differences is that TERM is exported in lp and set to the printer-type.
I'm guessing that your external program is doing some curses or stty stuff and that is what is killing you. You might look to see if your command has an argument to specify that
stdin/stdout in not associated with a terminal.

What external command are you running? Is it any sort of remsh?

Clay
If it ain't broke, I can fix that.
Colin_4
Occasional Contributor

Re: Problem on printer interface

Hi Clay,

I just got the reason. It's a stupid mistake I made. One of the program run in the interface is trying to redirect its stderr to a file which is created already and no write permission to user lp. That's why the whole interface is getting stuck over there. It also explains why I can run the script at shell because I login as root so I am always able to write anything into that file.

Thank you very much for your suggestion and quick responses. I deeply appreciate.

Take care,

Colin