I have a script that uses CUPS lpstat -h command. However, the remote server I am trying to get a response from asks for a password. But I need to execute this script from within Nagios, so I have two questions I am hoping someone can shed some light on.
First, does anyone know of a way to include the password when sending the lpstat command? Example would be: lpstat -h 192.168.1.106 -p PO1 the address is my remote server, PO1 is the name of the printer on that server. It seems cups left out a way to add a password to that command, so it comes up as a prompt.
Second, if I have a script that uses that lpstat command integrally, is there a way to execute the script AND send the password from one command? I tried to echo it but the prompt doesn't accept that. I don't see a prompt when executing the script, it just hangs until I enter my password and press enter, then it completes and outputs the result I need.
I tried using expect scripts, but since there is nothing to expect (if running the script that uses lpstat, I don't get an actual prompt), so I just sent "send" commands, which seems to execute the script but didn't pass on the output.
I'm stuck here, all the scripts I have found for remotely checking the status of a CUPS printer require user input, and unless I can find a way to do it in one line and output a result, I can't use it in Nagios.