[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Linux Script

Posted on 2011-02-23
6
Medium Priority
?
270 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 20

Accepted Solution

by:
simon3270 earned 2000 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 20

Assisted Solution

by:simon3270
simon3270 earned 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
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…

656 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