> Procedural nature of shell scripts | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Unix/Linux Go Back    


UNIX for Dummies Questions & Answers This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in this forum UNIX for Beginners Questions & Answers

Procedural nature of shell scripts

UNIX for Dummies Questions & Answers


 
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 03-13-2013
glev2005 glev2005 is offline
Registered User
 
Join Date: Oct 2008
Last Activity: 19 July 2014, 10:56 PM EDT
Posts: 276
Thanks: 20
Thanked 6 Times in 6 Posts
Procedural nature of shell scripts


Code:
#!/bin/bash
#this is script1
sleep 30

And

Code:
#!/bin/bash
#this is script 2
/path/to/script1.sh
echo im done

Running script 2 will give a 30 second pause and then echo Im done to the terminal. What behavior exactly, is responsible for waiting for script one to complete before the echo line is interpreted? Can someone please explain this mechanism? Does the shell wait for an exit status of any given command unless it is executed with a & at the end to send to background?

Thanks, I hope I am being clear.
Sponsored Links
    #2  
Old Unix and Linux 03-13-2013
vbe's Unix or Linux Image
vbe vbe is offline Forum Staff  
Moderator
 
Join Date: Sep 2005
Last Activity: 25 July 2016, 5:02 AM EDT
Location: Switzerland - GE
Posts: 6,272
Thanks: 228
Thanked 504 Times in 468 Posts
A bit of reading:
wait -- Wait for Child Process to End
Sponsored Links
    #3  
Old Unix and Linux 03-13-2013
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 26 July 2016, 12:40 PM EDT
Location: Saskatchewan
Posts: 21,399
Thanks: 962
Thanked 3,889 Times in 3,619 Posts
Quote:
Originally Posted by glev2005 View Post
Does the shell wait for an exit status of any given command unless it is executed with a & at the end to send to background?
That's exactly what it does. The exit status is available in $? afterwards, but usually is used more directly, since you can plug commands directly into an if-statement.
Sponsored Links
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Cant understand the File system working nature nokiak810 Solaris 2 11-21-2012 07:47 AM
Specification language suitable for procedural programs tsurko Programming 2 02-16-2009 04:41 PM
Unable to understand associative nature of awk arrays nervous UNIX for Dummies Questions & Answers 3 10-07-2006 06:03 AM



All times are GMT -4. The time now is 01:44 AM.