How to check status of last print command?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to check status of last print command?
# 1  
Old 01-11-2010
How to check status of last print command?

I am working on an Linux based application where I am using lp -onobanner -s -d$RPTDEST command to print the file on desired printer. Variable $RPTDEST could be different each time even for the same user. I need to implent the check if last print command was succesful or not, so that application can show an confirmation messasage to user with (problem description if possible).
I am not sure how to check the print status of perticular printer, can any one please help?

Thanks in advance....
# 2  
Old 01-11-2010
Hello dpmore,

you can also check the log files to see the success or failures of the command.
for e.g.
Code:
tail -f /var/log/lp.log

The name of the file may be same or different. Please check it. This will show the contents of the file in real time. whatever is written to the file is displayed in real time.
# 3  
Old 01-11-2010
Gaurav, thanks for the reply but I really need to do that as a part of shell script or C code. Reason behind this is, we do check the logs every time manualy and now we need to implement the popup for user to with status of his printing job.


Thanks...
# 4  
Old 01-11-2010
Have you tried testing what the value of $? holds? Immediately after your print statement, you could add an if statement similar to this:

Code:
lp -onobanner -s -d$RPTDEST
if [ $? -eq 0 ]  # If the last result equals 0, then it was successful
then
  echo "The command was successful"
else
  echo "It didn't work"
fi


Last edited by 2pugs; 01-11-2010 at 08:47 PM.. Reason: Grammar
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Check status of process

Hi All, Have a query How to check for a process and if down start it , try if for 2 times and its not starting don't do it My code is working to some extent but while starting try starting both times. Please advise , whats wrong here ? if you have any other approach please do share. My... (1 Reply)
Discussion started by: abhaydas
1 Replies

2. Shell Programming and Scripting

Check/get the exit status of a remote command executed on remote host through script

Geeks, Could you please help me out in my script and identify the missing piece. I need to check/get the exit status of a remote command executed on remote host through script and send out an email when process/processes is/are not running on any/all server(s). Here's the complete... (5 Replies)
Discussion started by: lovesaikrishna
5 Replies

3. Red Hat

Check PSU Status

Hello, We have a cluster and each server have 2 PSU. An alarm should be raised in case of failure so we need to check periodically the PSU status wth a script. The first idea was to check with ipmitool but this take some time to get the data and we face some other issues now due to that... (1 Reply)
Discussion started by: @dagio
1 Replies

4. UNIX for Dummies Questions & Answers

Check Success Status Of sed command

How do i check success status of a sed command execution i have the below script not sure if it is right approach to check status of execution using a function. Also it looks like in the below sed command even if the search string doesn't exist in the file it is returning status as success as i... (6 Replies)
Discussion started by: Ariean
6 Replies

5. Shell Programming and Scripting

Check HD status

I have some server ( IBM , Dell ) , our data center is not in the same location with office , therefore , I do not know if the HD lamp is flash when the HD is fault , can advise if I can write a script to check if the HD is normal running or not ? thanks (1 Reply)
Discussion started by: ust
1 Replies

6. UNIX for Dummies Questions & Answers

Check the exist status of the cd command

Hi, As in scripting , some cd commands getting failed, so we do check the exist status as 0 or 1. But every time we call to function for it. But does any single line exist will do the job with || , && ? i.e ls -l Logs cd Logss | exit echo hias Logss is not exist , Before printing "hi" we... (5 Replies)
Discussion started by: posix
5 Replies

7. Shell Programming and Scripting

How to check status of tar command?

Hi, How to check the status of tar command using bash script ? I have the following tar command, how to check the status of the tar? tar -cjf $today.tar.bz2 /opt/data Regards, Eye Gee (1 Reply)
Discussion started by: egkua
1 Replies

8. Shell Programming and Scripting

How to Check the process Status and do something

Hi we have weblogic deployed under Linux Enterprise 5 . Now i want to write a script that checks if weblogic is running or not I have found that weblogic uses Java as process . Can i do this way : my Script File : Echo Checking Status if then echo Server Running else echo... (2 Replies)
Discussion started by: Ravi Pavanv
2 Replies

9. Shell Programming and Scripting

Failed to check status code in "rsh" command

Hi folks, I wrote a ksh program which run scripts from remote server. To check the status code I wrote the following function: check_remote_status() { status_code=`tail -1 $installLog` if ] ; then echo $errMsg | tee -a $installLog exit 1 else echo $validMsg >> $installLog fi... (9 Replies)
Discussion started by: nir_s
9 Replies

10. Shell Programming and Scripting

check the status and send an email with status

Hi, We have a text file which has the following data. ISA~00~ ~00~ ~ZZ~VISTN ~ZZ~U1CAD ~051227~183 7~U~00200~000011258~0~P~< GS~FA~EE05J~U1CAD~051227~1831~000011258~X~002002 ST~997~0001 AK1~SH~247 AK2~856~2470001 AK5~A AK2~856~2470002 AK5~A... (3 Replies)
Discussion started by: isingh786
3 Replies
Login or Register to Ask a Question