Sponsored Content
Top Forums Shell Programming and Scripting Asynchronous shell scripts question - newbie Post 302482885 by taskeen21 on Wednesday 22nd of December 2010 10:02:23 PM
Old 12-22-2010
Quote:
Originally Posted by purdym
The command you may not know about is:
Code:
wait

.

You already have half the answer. See how wait can help you here.
Thank you. Yea, i came across "wait" through my search. And read about it. Please don't misunderstand me. I am not arguing in any way. I am just trying to understand how this will work exactly so I can convince the interviewer. So, in wait(n) 'n' can be a PID. If i don't specify 'n' the master script will wait for all scripts to finish and return and then continue the execution of further code. So, if i go with this approach how will i know what the PID of "script1 &" and "script2 &" is ?
OR if I go with the "wait", without arguments option, does it mean the script3 will read as simple as this :

<script3's code>
..........
script1 &
script2 &
wait( )
..........
<continue script3's code>

?

---------- Post updated at 06:54 PM ---------- Previous update was at 06:50 PM ----------

Quote:
Originally Posted by migurus
If this needs to be done using Unix shell scripts, then here is a possibility:
- there are three scripts
- scripts #1 and #2 each create a file upon completion, the file will signal OK or FAIL return code of the corresponding script
- script #3 (master) runs both scripts #1 and #2 in the background and waits for the resulting files. I will have a timeout here just in case
- when both files are OK files (meaning scripts #1 and #2 run OK) run the last procedure #3, otherwise say what went wrong
- always cleanup / remove the files from scripts #1 and #2

Just a note: To run a script in the background in unix one has to end the command with '&'
Thank you. That would be a good approach.

---------- Post updated at 07:02 PM ---------- Previous update was at 06:54 PM ----------

Thanks fpmurphy. You are awesome!
I got to know so many things from your sample code. $$ gives calling process' PID and $! gives the called process' PID.
I am sure I could always replace those functions with script file names.
Hats off to you guys. unix.com rocks!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

help for newbie writing shell scripts

Hi, I have just started a Systems Programming course and am required to write a c shell script as part of it. I have little to no clue about unix. The spec states that the script can be run only once on each host by a user, but the script can be run on different hosts by the one user. ... (2 Replies)
Discussion started by: richgi
2 Replies

2. Shell Programming and Scripting

two simple question on shell scripts....

:D my first question is how can envoke filename expansion from within a shell script.. forinstance if i execute the script and it asks for a specific directory that i would like to cd to, how can i get the script to use the same file name expension as the command line.. my second question is how... (3 Replies)
Discussion started by: moxxx68
3 Replies

3. Shell Programming and Scripting

shell scripts question

Hi I am trying to do the following use a shell script to draw from various online table to the table on my server. it draws from one online table which has a set of columns one of which is in the form say 2006ab i want to use this as input to copy into another column an http link that has... (0 Replies)
Discussion started by: wannabegeek
0 Replies

4. UNIX for Dummies Questions & Answers

shell scripting newbie question

Hi all! I'm a newbie to shell scripting. I want to create a script that will store a line from a text file in a variable so I can then use it to open firefox with that text in the address bar (the text file contains a list of addresses). I have tried the following: #!/bin/sh a='sed -n 2p... (2 Replies)
Discussion started by: jazzman
2 Replies

5. UNIX for Dummies Questions & Answers

UNIX newbie NEWBIE question!

Hello everyone, Just started UNIX today! In our school we use solaris. I just want to know how do I setup Solaris 10 not the GUI one, the one where you have to type the commands like ECHO, ls, pwd, etc... I have windows xp and I also have vmware. I hope I am not missing anything! :p (4 Replies)
Discussion started by: Hanamachi
4 Replies

6. Shell Programming and Scripting

Newbie question-do I pause and exec my shell scripts?

Hi there, I'm writing a script to restore 3 directories and 3 mysql db's every 24 hours. While writing the script, I came across the thought... Do I need to pause between executions? Example: msql restore1.sql rm -Rf path1/* cp -Rf path1/* /restore1 chmod 777 /folder1/cache1 ... (2 Replies)
Discussion started by: semiotics101
2 Replies

7. Shell Programming and Scripting

Newbie Question: Killing a process using a supplied name to a shell script

Hi, I am trying to automate the killing of named processes of which I found a good solution here on the forums but as I am pretty much a begginer to linux I am having an issue. The code I found is: kill $(ps -ef | nawk '/monitoreo start/ { print $2}'} but what I want to do is replace... (3 Replies)
Discussion started by: TylrRssl1
3 Replies

8. Shell Programming and Scripting

Newbie Question: What is php shell scripting?

I know php is a Web Development language but what does it have to do with shell scripting. I might be wrong about php. Is there a CLI? How do I make one and how does it work? Please don't answer these if you have any books on this. Please give names of good beginner books for php shell scripting... (3 Replies)
Discussion started by: orszhak
3 Replies

9. Programming

need help with shell script filtering files and sort! newbie question?

Hi folks, I would like to get familiar with shell script programing. The first task is: write a shell script that: scans your home-folder + sub-directory for all txt-files that all users of your group are allowed to read and write then output these files sorted by date of last... (4 Replies)
Discussion started by: rollinator
4 Replies

10. Shell Programming and Scripting

General question about passing variables among shell scripts

So this is something I've been wondering how to do for a while. Suppose I have two shell scripts a.sh and b.sh script a does some function and outputs to a varable $x . I would then like to take $x into the second function, b.sh, and do a function on it and create some output. So how do you pass... (3 Replies)
Discussion started by: viored
3 Replies
GPT-POSTINSTALL(8)					User Contributed Perl Documentation					GPT-POSTINSTALL(8)

NAME
gpt-postinstall - Searches for post install scripts and executes them SYNOPSIS
gpt-postinstall [-help -force -version -man -location ] DESCRIPTION
gpt-postinstall Searches an installation for post-install scripts that have not been run yet and executes them. These scripts are installed by Setup packages and are designed to localize an installation. The -force flag can be used to re-run all of the setup scripts. OPTIONS
-force forces all action to be taken, regardless of state. -help Print a brief help message and exits. -man Prints the manual page and exits. -version Prints the version of GPT and exits. -location Location indicates the path to the Globus installation that will be used. SEE ALSO
gpt-install(1) gpt-uninstall(1) gpt-verify(1) AUTHOR
Michael Bletzinger <mbletzin.ncsa.uiuc.edu> and Eric Blau <eblau.ncsa.uiuc.edu> perl v5.14.2 2012-04-30 GPT-POSTINSTALL(8)
All times are GMT -4. The time now is 04:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy