how to make some condition when program/tool unsuccesfully ends with error..


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to make some condition when program/tool unsuccesfully ends with error..
# 1  
Old 03-18-2010
Question how to make some condition when program/tool unsuccesfully ends with error..

Simply, when i have tool "pdftotext", "sed" or "wget" and if this tool make an error in converting or downloading or something, I want to terminate my script...something like:

if [ pdftotext throws error/exception ]; then
exit 1
fi

bud I dont know how..can you help guys?Smilie
# 2  
Old 03-18-2010
Code:
pdftotext <arg..>

if [ $? -eq 0 ]; then
  echo "Success"
else
  echo "Failed"
  exit 1
fi

# 3  
Old 03-18-2010
what does [ $? -eq 0 ] means

//ah i've already noticed the $? is number of errors occured.

thanks

Last edited by Lukasito; 03-18-2010 at 04:25 PM..
# 4  
Old 03-18-2010
Quote:
Originally Posted by Lukasito
what does [ $? -eq 0 ] means
Have a read of this: Exit and Exit Status
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Make expect exit the UNIX script in erreneous condition

Hi, I am writing a menu driven program using shell script. THe script will be collecting data by logging into the other servers and bringing back the data to home server to process it and accordingly issue commands. TO automate commands execution , I am using expect script. However I am not able... (5 Replies)
Discussion started by: ashima jain
5 Replies

2. Solaris

Gani Network Driver Won't Install - make: Fatal error: Don't know how to make targ...

I attached a README file that I will refer to. I successfully completed everything in the README file until step 4. # pwd /gani/gani-2.4.4 # ls COPYING Makefile.macros gem.c Makefile Makefile.sparc_gcc gem.h Makefile.amd64_gcc ... (1 Reply)
Discussion started by: Bradj47
1 Replies

3. Programming

Help with a C program that acts like the make utility

Hi, I'm trying to create a C program that functions like the make utility in UNIX for personal use. My program would read in from a generic makefile and execute whatever is in that makefile but I'm not sure as to where I should start coding. I would appreciate any help. Thanks. (1 Reply)
Discussion started by: kratos.
1 Replies

4. Programming

In unix how we can test or check race condition in c program by using multi threads

In unix how we can test or check race condition in any c program by using multi thread programming (5 Replies)
Discussion started by: afroze
5 Replies

5. UNIX for Dummies Questions & Answers

In unix how we can test or check race condition in a c program by using multi threads

In unix how we can test or check race condition in any c program by using multi thread programming (1 Reply)
Discussion started by: afroze
1 Replies

6. Shell Programming and Scripting

Make program only run by root

Hi all, i hope i got this in the right place, what i am trying to do is make a program only run by root, ie for instance user fred is logged in and uses firefox, what id like to do is change that so that when fred wants to use firefox he will be asked to enter root password before he is allowed to... (14 Replies)
Discussion started by: dave123
14 Replies

7. Linux

How to make a tool as 30-days evalution copy

Hi All, I am very curious to know that how to make a product/tool as evalution copy(trail version for 30days). I want to know this implemention process in linux(the tool is in Linux). If anybody have any scripts/articles/ideas please pass them to me. Please help me. Thanks in Advace,... (0 Replies)
Discussion started by: uday123
0 Replies

8. Programming

Tool for make file

Hi, so far i am writting make file explicitly, is there is any tool is there to write make file automatically....if so please tell me about that... Thanks in advance Sarwan (4 Replies)
Discussion started by: sarwan
4 Replies

9. AIX

big brother monitoring tool - make failed

Hi, Does anyone has installed bb on a unix system ? I am trying to install bb on aix 5.3 but I have the following message: If someone can help me probably there is a tool that I need to install ? I don't have C compiler I install gcc instead and gcc++ etc ... bb:/home/bb/bb1.9g-btf/src/ $ make... (0 Replies)
Discussion started by: touny
0 Replies

10. UNIX for Dummies Questions & Answers

Is there any non graphical tool that make selective merge between text files?

whitout using awk / sad and so on? (3 Replies)
Discussion started by: umen
3 Replies
Login or Register to Ask a Question