The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Threads help smurf2 High Level Programming 1 05-15-2009 01:51 PM
Threads in Unix shell script kum5256 Shell Programming and Scripting 1 04-16-2008 03:45 AM
Threads and Threads Count ? varungupta UNIX for Advanced & Expert Users 2 03-21-2008 09:23 PM
old threads norsk hedensk Post Here to Contact Site Administrators and Moderators 2 06-03-2003 05:16 PM
nfs threads i2admin UNIX for Advanced & Expert Users 1 03-06-2003 11:28 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-02-2009
som.nitk som.nitk is offline
Registered User
  
 

Join Date: Nov 2008
Location: Pune, India
Posts: 23
threads in ksh script

Hi Unix Gurus,
Please guide me on how to simulate threads in korn-shell scripting. I am new to ksh scripting.

What I want is a simple 2 liner code to create two threads and then run two parallel jobs in these two threads at the same time. Also please tell me how to catch the return code in each of these threads.

As far as I know threads are not there in ksh, but I heard creating a sub-shell would create the effect.
Please guide.
Thanks
  #2 (permalink)  
Old 07-02-2009
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,643
I think you must mean coprocesses. Search the forums for coprocess, there are a lot of examples.
  #3 (permalink)  
Old 07-03-2009
cfajohnson's Avatar
cfajohnson cfajohnson is online now Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,309

Code:
command1 & p1=$!
command2 & p2=$!

wait $p1; r1=$?
wait $p2; r2=$?

echo r1=$r1
echo r2=$r2
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 11:46 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0