?
Solved

Linux Script

Posted on 2011-02-23
6
Medium Priority
?
269 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 19

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 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

PowerShell Core for Advanced Linux Administrators

Understand advanced principals around Powershell Core with a focus on the Linux Administrator.  This course covers how to administer numerous environments across multiple platforms including Linux, Azure, AWS, and Google Cloud from a single shell instance.

Question has a verified solution.

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

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
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…
Suggested Courses

765 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