Solved

Linux Script

Posted on 2011-02-23
6
264 Views
Last Modified: 2012-05-11
I am writing a linux script to automate a few commands I wish to run on my machine.  My question is this:

I have about 5 -10 commands I need to run in the script.  But there are a few commands that I need it to open up a new shell and run them seperately from the others.

Example:

Commands 1-4 in one shell
5-6 in another shell
7-9 in a third shell for a total of 3 shells when the script completes.

How do I tell the script to open a new shell when running one of the specific commands?  Is that possible?
0
Comment
Question by:cbur2107
  • 2
  • 2
  • 2
6 Comments
 
LVL 19

Accepted Solution

by:
simon3270 earned 500 total points
ID: 34964911
How about:

(command1;command2;command3;command4) &
(command5;command6) &
(command7;command8;command9)&

this starts off three subshells in the background.
0
 
LVL 1

Author Comment

by:cbur2107
ID: 34964976
i will give that a try and let you know.

Thanks.

0
 
LVL 8

Expert Comment

by:point_pleasant
ID: 34970716
simon3270's should work fine as long as there is no inter-dependence between results or actions from or between shell1 shell2 and shell3. obviously command1;command2;command3 and command4 will run sequentially but you may run into the case where command5 thru command89 finish ahead of command1.  By putting the three shells in background all three will start executing immediately.  if that is what you want then it should work fine.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:cbur2107
ID: 34972459
So how do you tell the script to start one command AFTER another rather than all executing immediately...?
0
 
LVL 8

Expert Comment

by:point_pleasant
ID: 34972979
you could have the last line of script one call script two and the last line of script 2 call script three.
0
 
LVL 19

Assisted Solution

by:simon3270
simon3270 earned 500 total points
ID: 34975393
or just miss out the ampersands.

(command1;command2;command3;command4)
(command5;command6)
(command7;command8;command9)

will run commands 1, 2, 3 and 4, one after the other, in one shell.  Then when command 4 finishes, that first shell finishes.  Command 5 followed by command 6 then runs in a second shell.  That shell then finishes and commands 7, 8 and 9 run in a third separate shell.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Vbscript 8 79
Running Visio Macro from VBS File 3 58
Linux Scripting 3 102
Sending Attachment via CDO 3 58
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Utilizing an array to gracefully append to a list of EmailAddresses
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now