View the Most Wanted LQ Wiki articles.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 07-02-2009, 03:35 PM   #1
LQ Newbie
Registered: Jul 2009
Posts: 2

Rep: Reputation: 0
Executing multiple instances of a binary file from a single script?

Hi guys,

I'm a Linux newbie and I've been using Debian 4.0 for a few months now, trying different things and getting to grasps with the basics.

My question is about ways of executing a binary (.bin) file from a script.

I've setup a gameserver for FEAR Combat. After copying the files into the home directory for the 'fear' user I created for the purpose, you then execute a script called which links to a library file then execute the game binary file (fearserver.bin).

This is the script


This all works fine, but then I tried to take things further and run 3 separate instances of the server on 3 separate ports.

I first tried calling/executing the binary 3 times in a row in the script, however what happens is that the first instance loads and runs and the script pauses there until you terminate the instance, and then the second instance is executed and so on...


My workaround (which does actually work) so far has been to create a separate script for each of the instances I'm trying to create, then I open up a remote console session to the Debian machine using Putty/SSH on Windows XP, login as the fear user I created, execute the script for the first instance of the binary, then close the session window without logging out. The .bin continues to run on the system. I then repeat this twice more and end up with the desired 3 instances of the binary all running AT THE SAME TIME under the fear user account.

So my question is can I get the same result launching the instances from the same script from a single session, rather than having to open a separate session to launch each instance?

Any help much appreciated!

Old 07-02-2009, 04:15 PM   #2
LQ 5k Club
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,063

Rep: Reputation: 388Reputation: 388Reputation: 388Reputation: 388
I know nothing about fearserver but have you tried "putting in the background"?

With bash you can run a command "in the background", and not wait for it to complete / finish and terminate before you get the prompt back. So you can issue another command straight away. The process running "in the background" just carries on, but gives you your shell prompt back. Errors are generally reported back to the shell you are in, unless you redirect them.

You can do this by appending & to the command. Like this:
./fearserver.bin &
It's worth a try.

See man bash for the full story.

And Welcome to LQ!.
Old 07-02-2009, 04:35 PM   #3
Senior Member
Registered: Mar 2004
Location: england
Distribution: Debian, Mint, Puppy, Raspbian
Posts: 3,371

Rep: Reputation: 192Reputation: 192
why multiples?
a good server should handle spawning instances itself usually.
do they not all try to bind the same port?
usually a service will have a startup script which you can activate on boot.

also the servers may die if you call them from an interactive
script and you close the window.

have you checked the docs to see if the server can daemonize properly?

FYI look at:

man at
man nohup
Old 07-02-2009, 05:56 PM   #4
LQ Newbie
Registered: Jul 2009
Posts: 2

Original Poster
Rep: Reputation: 0

Hi guys,

Tredegar - Adding the 'run in background' did the trick! That's exactly what I was after - useful technique to know and a nice simple answer

I've now created a single script that does everything.

Interestingly it does dump the 'initial' text output of each instance to the console, but this time all at once. There is no 'prompt' visible afterwards on the console, but as soon as I start typing it accepts it as a new command and the server instances disapear into the background. Just a quirk though, doesn't interfere with anything.

Bigearsbilly - The fearserver by default runs on port 27888. To change any of the settings (including the port) you have to specify an optionsfile when executing the file. I didn't mention this previously as it wasn't really relevant.

So my 'combined' startup script looks like this:

./fearserver.bin -optionsfile /home/fear/FEAR/ServerOptions/ServerOptions-SMTDM $
./fearserver.bin -optionsfile /home/fear/FEAR/ServerOptions/ServerOptions-SMDM $
./fearserver.bin -optionsfile /home/fear/FEAR/ServerOptions/ServerOptions-SMCTF $

Having 3 instances lets me have the option of 3 different game modes. I could make the script run at startup but would prefer to start the servers manually...

I can confirm the 3 instances laucnhed from the single script are all running smoothly and are being thoroughly tested

Thanks for all your help guys!


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
bash script iterating multiple instances of java GUI on different desktops rockdiablo Linux - Desktop 2 06-23-2009 08:35 AM
Storing multiple options in a single variable (binary addition?) matt_heys Programming 1 04-03-2009 04:38 PM
Preventing multiple instances of a shell script from running concurrently Dave Lerner Programming 12 01-03-2007 10:27 PM
executing a script in multiple subdirectories jerryfreak Linux - Newbie 1 04-19-2005 09:34 PM
Difficulty executing a binary file Judland Linux - Software 2 10-04-2003 12:03 AM

All times are GMT -5. The time now is 04:41 AM.

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