LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 01-25-2012, 09:55 AM   #1
metallica1973
Senior Member
 
Registered: Feb 2003
Location: Washington D.C
Posts: 2,190

Rep: Reputation: 60
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: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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: 2,190

Original Poster
Rep: Reputation: 60
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: 244Reputation: 244Reputation: 244
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: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Using ASCII character codes in a shell script (Linux) Twelveone Programming 2 02-07-2020 12:54 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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:46 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration