For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > June 2006 > bash exec in background









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author bash exec in background
John Smith

2006-06-17, 8:21 am

I am using cygwin's bash.exe. I am running cygwin on a Win XP box.

I am trying to start up 4 server processes, the 4 need to be running
concurrently.

1) can i start them up with 1 bash shell?
2) if so, how to run them concurrently in the background?

what i have tried and failed:
exec "a.cmd" // the closest i came; but the a.cmd runs and hangs,
waits for incoming connection; b, c, d, never got executed
exec "b.cmd"
exec "c.cmd"
exec "d.cmd"

exec start "a.cmd"
exec start "b.cmd"
exec start "c.cmd"
exec start "d.cmd"

cmd "a.cmd"
cmd "b.cmd"
cmd "c.cmd"
cmd "d.cmd"

"system" is not installed on my cygwin.

any help and hints are appreciated.
P.S. tried RTFM and STFW as follows but no dice:
http://ca.php.net/manual/en/function.exec.php
man exec
man system
man cmd

Chris F.A. Johnson

2006-06-17, 8:21 am

On 2006-06-09, John Smith wrote:
> I am using cygwin's bash.exe. I am running cygwin on a Win XP box.
>
> I am trying to start up 4 server processes, the 4 need to be running
> concurrently.
>
> 1) can i start them up with 1 bash shell?
> 2) if so, how to run them concurrently in the background?
>
> what i have tried and failed:
> exec "a.cmd" // the closest i came; but the a.cmd runs and hangs,
> waits for incoming connection; b, c, d, never got executed
> exec "b.cmd"
> exec "c.cmd"
> exec "d.cmd"


With the first exec, you replace the current process with b.cmd;
the shell process no longer exists.

To put a command into the background, follow it with an ampersand:

b.cmd &
c.cmd &
d.cmd &


--
Chris F.A. Johnson, author <http://cfaj.freeshell.org>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com