LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 01-12-2010, 12:29 PM   #1
ufmale
Member
 
Registered: Feb 2007
Posts: 385

Rep: Reputation: 30
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?
 
Old 01-12-2010, 12:51 PM   #2
David1357
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
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by ufmale View Post
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.
 
Old 01-13-2010, 08:23 AM   #3
anand.arumug
Member
 
Registered: Oct 2009
Location: Dayton, Ohio
Distribution: ubuntu, centos
Posts: 68
Blog Entries: 2

Rep: Reputation: 16
Quote:
Originally Posted by David1357 View Post
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.
 
Old 01-13-2010, 06:13 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,357

Rep: Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
to 'start only' a shell script on boot up aj_1988 Linux - Newbie 2 01-12-2009 09:19 PM
start application using shell script Skiltron Linux - Software 2 12-24-2008 12:51 PM
Timed shell script start lpn1160 Linux - General 1 01-05-2006 12:00 AM
Start programs from a shell script paraiso Linux - Newbie 4 04-29-2005 09:41 AM
Shell Script to Start NVU Dooley Linux - Software 5 07-13-2004 07:12 PM


All times are GMT -5. The time now is 02:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration