Solved

Linux Script

Posted on 2011-02-23
6
266 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

808 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