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

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Procedural nature of shell scripts

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 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 03-13-2013
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
 
Join Date: Sep 2005
Last Activity: 19 December 2014, 1:20 PM EST
Location: Switzerland - GE
Posts: 5,980
Thanks: 171
Thanked 440 Times in 412 Posts
A bit of reading:
wait -- Wait for Child Process to End
Sponsored Links
    #3  
Old 03-13-2013
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 19 December 2014, 8:26 PM EST
Location: Saskatchewan
Posts: 20,037
Thanks: 855
Thanked 3,457 Times in 3,229 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
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 08:47 AM
Specification language suitable for procedural programs tsurko Programming 2 02-16-2009 05:41 PM
Unable to understand associative nature of awk arrays nervous UNIX for Dummies Questions & Answers 3 10-07-2006 07:03 AM



All times are GMT -4. The time now is 04:37 AM.