Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
01-12-2010, 01:29 PM
|
#1
|
Member
Registered: Feb 2007
Posts: 386
Rep:
|
start applications with shell script
I am trying to start multiple application with a shell script,but have no idea how to do it.
Basically, i want to start the same application in different directories, say consumer1/app, consumer2/app, consumer3/app
I was thinking about writing a script like:
-------------------
cp app consumer1/
execute consumer1/app
cp app consumer2/
execute consumer2/app
.
.
.
-------------------
My problem is that I don't know how to execute to app
(execute consumer2/app) in such a way that the script can continue.
Does anyknow have a solution for me?
|
|
|
01-12-2010, 01:51 PM
|
#2
|
Senior Member
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Rep: 
|
Quote:
Originally Posted by ufmale
My problem is that I don't know how to execute to app (execute consumer2/app) in such a way that the script can continue.
|
Use syntax like this
Code:
consumer2/app >> /dev/null 2>&1 &
or
nohup consumer2/app >> /dev/null 2>&1 &
The first will start the application in the background with all output redirected to "/dev/null". The second will disconnect the application from the terminal so it will not die when you exit your shell.
|
|
|
01-13-2010, 09:23 AM
|
#3
|
Member
Registered: Oct 2009
Location: Dayton, Ohio
Distribution: ubuntu, centos
Posts: 68
Rep:
|
Quote:
Originally Posted by David1357
Use syntax like this
Code:
consumer2/app >> /dev/null 2>&1 &
or
nohup consumer2/app >> /dev/null 2>&1 &
The first will start the application in the background with all output redirected to "/dev/null". The second will disconnect the application from the terminal so it will not die when you exit your shell.
|
the program you use to copy the application "cp" is invoked in the script just by its name, so wont the application you want to execute in different directories will also execute by just calling them by their executable name? or am i missing something? That is,
Code:
cp app ./dir1
app&
cp app ./dir1
app&
...
I guess you might want to be " nice" before you start all the programs so that everything runs with equal amount of cpu time.
|
|
|
01-13-2010, 07:13 PM
|
#4
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,426
|
The prog will be called by searching your $PATH, unless you specify a relative or absolute path.
Running a prog in different dirs can mean 1 of several things
1. run the (one version) of the prog and pass the dir to use as a cmd line param, if it accepts that method.
2. have a separate copy of the prog in each desired dir and cd into that dir and call it with ./prog
3. cd into the desired dir and call the prog via $PATH
4. cd into the desired dir and call the prog using an absolute path
5. cd into the desired dir and call the prog using a relative path
Incidentally, it's
prog &
not
prog&
to background a prog; note the space there.
To avoid the prog terminating when you logout, add nohup thus
nohup prog &
HTH
|
|
|
All times are GMT -5. The time now is 09:14 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|