LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-13-2015, 11:54 PM   #1
sagar666
Member
 
Registered: Feb 2013
Posts: 212

Rep: Reputation: Disabled
wait script


Hi

I have script1.pl and script2.sh.

I want to run first script1.pl once it finish the job..Inside script1.pl itself i want to call script2.sh.

So i am planning get pid of script1.pl and using this pid to give wait command to run second script

Below script is not work can anyone please help me for correct script for above usage.

echo "starts to run second script"
wait $$
sh ./script2.sh
 
Old 01-14-2015, 02:11 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
I do not really understand that.
simply write:
script1.pl; script2.sh
or even better:
script1.pl && script2.sh
 
Old 01-14-2015, 03:23 AM   #3
sagar666
Member
 
Registered: Feb 2013
Posts: 212

Original Poster
Rep: Reputation: Disabled
Hi Pan,

I need to run script2.sh when script1.pl pid ends that is my requirement
 
Old 01-14-2015, 03:50 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by sagar666 View Post
Hi Pan,

I need to run script2.sh when script1.pl pid ends that is my requirement
That is what "script1.pl && script2.sh" do. The shell runs the first one (and waits for the child pid to exit) then runs script2.sh, if script1.pl doesn't have an error.

If you want both to run, no matter what, then use "script1.pl; script2.sh".
 
Old 01-14-2015, 04:21 AM   #5
preetham.66666
Member
 
Registered: Jan 2015
Posts: 33

Rep: Reputation: Disabled
Hi,

Thing is script1.pl inside have several functions
Input to script1.pl will get it from another script (inputs example 1 2 3)

Say
If it is 1
Then
Run some thing
If it is 2
Then
Run some thing
If it is 3
Then
Run some thing
If it is 3
Then
Run some thing
.
.
.

Suppose input is 2 then i want run script2

Suppose input is 5 then i want run script5


Note script1.pl parallel runs

This is my requirement

Last edited by preetham.66666; 01-14-2015 at 04:23 AM.
 
Old 01-14-2015, 05:30 AM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
That sounds like homework.

You might read the man page on bash. There are a number of programming constructs that allow that.
 
Old 01-14-2015, 05:57 AM   #7
preetham.66666
Member
 
Registered: Jan 2015
Posts: 33

Rep: Reputation: Disabled
Its not a home work ..please share me logic so i can do it by own
 
Old 01-14-2015, 06:30 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
do you think something like this: http://bash.cyberciti.biz/guide/The_case_statement ?
 
  


Reply

Tags
linux, processes, programming, scripting



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
Waking script from wait state waddles Slackware 4 04-23-2013 09:33 PM
Wait for a remote script to finish before executing another vikas027 Programming 4 08-07-2012 01:48 AM
Simple script to wait for another script Maverick1182 Linux - Newbie 4 11-05-2007 03:45 AM
How to make a script wait for input farmerjoe Linux - General 2 12-28-2004 05:18 AM
Make script wait for input farmerjoe Linux - General 4 12-28-2004 01:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 05:09 PM.

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