LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 01-25-2012, 09:55 AM   #1
metallica1973
Senior Member
 
Registered: Feb 2003
Location: Washington D.C
Posts: 1,966

Rep: Reputation: 55
Bash Shell Script Exit Codes


Here is my daily stupid question:

How can I tell a script to only execute if the other scripts exits successfully?

So "script A" executes and if it executes successfully (0),then "script B" will run

or else

"script A "executes and it exits unsucessfully (1) then "script B" will read return code (1) and will not execute

Last edited by metallica1973; 03-14-2012 at 01:46 PM.
 
Old 01-25-2012, 10:19 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Slackware 13.37, Debian Squeeze
Posts: 7,987
Blog Entries: 25

Rep: Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009
my_script_A.sh && my_script_B.sh
 
Old 01-25-2012, 10:25 AM   #3
metallica1973
Senior Member
 
Registered: Feb 2003
Location: Washington D.C
Posts: 1,966

Original Poster
Rep: Reputation: 55
So a Boolean operator "AND" (&&)

Many thanks
 
Old 01-25-2012, 10:52 AM   #4
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 241Reputation: 241Reputation: 241
When used in this context, && is a control operator
 
Old 01-25-2012, 11:14 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Slackware 13.37, Debian Squeeze
Posts: 7,987
Blog Entries: 25

Rep: Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009
Quote:
Originally Posted by Cedrik View Post
When used in this context, && is a control operator
+1 to that and more specifically a "command list control operator". More info here.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Using ASCII character codes in a shell script (Linux) Twelveone Programming 1 06-11-2008 11:45 AM
capturing error codes in bash script nikaudio Linux - General 2 04-09-2008 08:56 AM
what is the script which runs at the exit bash shell supersubu123 Linux - General 6 01-24-2007 12:25 PM
Bash scripting problem with exit codes Jeiku Programming 2 05-15-2006 01:22 AM
Alias or shell script to confirm 'exit' commands from a shell rose_bud4201 Programming 2 03-08-2006 02:34 PM


All times are GMT -5. The time now is 11:16 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration