LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-04-2006, 06:34 PM   #1
helptonewbie
Member
 
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 518

Rep: Reputation: 39
Smile How can i run two bash scripts at same time?


Hello,
I would like to know how i can run two or three bash scripts at the same time all of them being called from another script. Currently i use
/file1 | /file2 | /file3
but there must be a better way as what i really want is to do something like this

# "lots of commands in the script file"
# then use a command to run file
/file1 # whilst this is executing, carry on with the
# rest of the scripts in this current file instead of having
# to wait for completion of the newly executed file
echo "blah blah"
if [ la la la ]; then
ta ta ta
fi

Thanks very Much for any ideas
 
Old 09-04-2006, 06:49 PM   #2
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
Append "&" to the command, as in
Code:
(sleep 2; echo "slept two seconds") & echo "second command"
This will launch a background process for the command, which is also a very common thing to do from the console, as the shell will immediately be available again without being blocked by the running program.

Maybe you should have a look at some Bash introduction like this one.
 
Old 09-05-2006, 05:00 PM   #3
jerp
LQ Newbie
 
Registered: Aug 2006
Posts: 5

Rep: Reputation: 0
I use exec and save the PID to a variable. That way I can manipulate the process if necessary, or check to see if it's still running.
 
Old 09-05-2006, 06:25 PM   #4
helptonewbie
Member
 
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 518

Original Poster
Rep: Reputation: 39
Smile

Hello, Thanks for repling.
I have managed to get a good kind of result by doing this:-
(thanks spirit, i used that site sugested)
/filepath/file1 &

that runs the command in the background as a seperate thing, however Jerp, i'd be interested to hear more about your idea. Could you show me a script or example of your method please

Thanks Again all
 
  


Reply



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
How to run Bash scripts like thread in Java? nguyenzoro Linux - General 1 11-11-2005 02:08 AM
Cannot run install sh scripts, and bash is FUBAR...what to do? asdfjkl Linux - Software 5 11-20-2004 09:09 PM
Suitable place to run bash scripts Skyline Programming 7 01-21-2004 07:37 PM
How to Run perl scripts using bash Boudewijn Linux - Software 2 11-26-2003 03:37 AM
bash scripts won't run aamehl Linux - General 10 09-06-2003 02:25 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:03 AM.

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
Open Source Consulting | Domain Registration