Printer status script giving error

Hi,

We check the printer status at the command line by giving the following command and the system gives an output;

lpstat -prn001_hp4000n

When I give the same command in a UNIX script the system gives an error while running the script as "lpstat: not found".

Please let me know how I could include this in the script to get the output.

can you post the line of lpstat line in your script...

---------- Post updated at 05:11 PM ---------- Previous update was at 05:09 PM ----------

try the below code...

status=`lpstat -prn001_hp4000n`

if [ $status -eq "0" ]; then
echo "success"
else
echo "failed"
fi

Hi,

The line on the script is as follows and what we require is to send the output of the command to a file;

lpstat -prn001_hp4000n >> $PRINSTAT

But the system was giving the error as I had mentioned earlier and no output is found.

 
When I give the same command in a UNIX script the system gives an error while running the script as "lpstat: not found". 

That mean , lpstat is not installed or not included in your path list.

If you are getting the output in command line.. then use the lpstat absolute path in your script.

just execute the following command

which lpstat

use the output of the above command in your shell script ( absolute path )

Hi,

When i give the command at the command line it give the output of the status of the printer perfectly. The problem is while I include this in this script then it is giving the problem. Hope I am clear.

Please post what itkamaraj asked. We suspect that the directory containing the program lpstat is not in your $PATH when run from your script.

From the command line session where it works:

which lpstat

Another more obscure reason might be if the script was edited on a Microsoft platform and then copied to a unix platform without special conversion.

Hi,

How can we create a lpstat for a printer. Is there a way of creating it so that we can see the status as mention earlier. Please help.

We seem to be going round in circles.

The error message "lpstat: not found" means that unix cannot find the command called "lpstat". If the "lpstat" command works from the command line then this means that the program "lpstat" is installed and working.
If it behaves differently from a script there must be a reason. The likely reasons have been suggested in earlier posts but without knowing what Operating System you have or where lpstat is installed or seeing a sample script we are flying blind.