Printer status script giving error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Printer status script giving error
# 1  
Old 05-10-2010
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;

Code:
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.
# 2  
Old 05-10-2010
can you post the line of lpstat line in your script...

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

Quote:
Code:
lpstat -prn001_hp4000n

try the below code...

Code:
status=`lpstat -prn001_hp4000n`

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

# 3  
Old 05-10-2010
Hi,

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

Code:
lpstat -prn001_hp4000n >> $PRINSTAT

But the system was giving the error as I had mentioned earlier and no output is found.
# 4  
Old 05-10-2010
Code:
 
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.

Last edited by panyam; 05-10-2010 at 09:41 AM..
# 5  
Old 05-10-2010
Quote:
Originally Posted by jmathew99
Hi,

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

Code:
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.

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

just execute the following command

Code:
which lpstat

use the output of the above command in your shell script ( absolute path )
# 6  
Old 05-10-2010
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.
# 7  
Old 05-10-2010
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:

Code:
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Find command giving bad status error

In a fastload teradata utility I am trying to delete the files which are older than 30days using the find and rm command as following. find . -name 'xxx_*' -mtime +30 -exec rm -f {} \; I expect it to delete all the files older than 30 days but sometimes it gives an error : find: bad status--... (3 Replies)
Discussion started by: stelkar
3 Replies

2. Shell Programming and Scripting

Script giving error-Unable to identfiy

#!/bin/sh #!/bin/prel #set -x while getopts ":n:t:" opt; do case "$opt" in n) host=$OPTARG ;; t) targ=$OPTARG ;; *) break ;; esac done if ping -c 2 $host >/dev/null 2>&1 then echo Host... (17 Replies)
Discussion started by: Vishal_dba
17 Replies

3. Shell Programming and Scripting

script to kill a pid giving error

Hi, I simply want to kill a running process using a script that read pid from a file and tries to kill it .Getting error as shown below code.. cat $HOME/BackupScript.ksh.run | head -1 | while read pid do ps -p $pid > /dev/null 2>&1 if ; then kill -9 $pid else echo "no running $pid... (5 Replies)
Discussion started by: dhirajdsharma
5 Replies

4. Shell Programming and Scripting

Script working in AIX, but giving error in SOLARIS

Hi, My script is working fine in AIX but throwing an error in SOLARIS system. Here is the error message that I am getting when calculating the elapsed time: /home/x772525/FindETA.sh: start_mins = *60 + : syntax error . ((start_mins = $(expr substr "$j" 1 2)*60 + $(expr substr "$j" 4... (6 Replies)
Discussion started by: ajayakunuri
6 Replies

5. AIX

Generic Printer giving garbage fonts in Arabic

Generic Printer giving garbage fonts in Arabic ! Guy's I have confgured this printer in AIX 6.1 by the following steps ... Smitty Print Spooling AIX Print Spooling Add a Print Queue I Selected from the box this kind hpJetDirect Network Printer (HP JetDirect) then ... (7 Replies)
Discussion started by: ITHelper
7 Replies

6. Shell Programming and Scripting

A running Script giving error while scheduled in cronjob

Hi, I have script which is properly running but when i schedule it in cron it throws an error like : Your "cron" job on retrprdapp1 /usr/bin/sh /retr/cron/ftp.sh 2>&1 produced the following output: /retr/cron/ftp.sh: syntax error at line 17: `(' unexpected line17 is # Get list of... (10 Replies)
Discussion started by: rajagasti
10 Replies

7. UNIX for Advanced & Expert Users

script giving error

Hi All, i have an small issue... echo " " eval x=$@ export x=`echo $x` echo $x ssh user@ipadrss; cd /mbbv/home/; cd /mbbv/home/orange/orange/ echo pwd bash samplescript.sh $x above is my script which will triger from server A and will connect to server B for some... (2 Replies)
Discussion started by: Shahul
2 Replies

8. Shell Programming and Scripting

mv command is giving error in shell script

Hi, In my shell script when I am using mv command using shell variables it is giving me error of syntax. Following is the shell script: file_edifice="*.txt" fquote="'" fdquote=\" for file in $file_edifice do file_name=$fquote$file$fquote tofile_name=`date... (5 Replies)
Discussion started by: gammit
5 Replies

9. Red Hat

Installing RedHat 8.0 onto Dell PowerEdge SC1425 - hdc: status error: status = 0x58

I have successfully installed RedHat 8.0 onto a Dell PowerEdge SC1425 today. This server has two SATA hard drives, and an IDE DVD-ROM drive. Using the following kernel parameters, i successfully installed across both hard drives from CD: ide0=0x1f0,0x3f6,14 vga=791 resolution=1024x768 expert... (5 Replies)
Discussion started by: fishsponge
5 Replies

10. Programming

printer status for print spooler: help

Hey people I am currently working on a print spooler for unix over a network. I need help regarding the status of the printer. Is there any way to know when the printer has finished a previous job, so that the next job from the queue can be processed. Also is there any other way to print other... (0 Replies)
Discussion started by: rage
0 Replies
Login or Register to Ask a Question