http://qs321.pair.com?node_id=359119

GaijinPunch has asked for the wisdom of the Perl Monks concerning the following question:

I've got a script that kicks off an app for a user. The developer likes to release things in "useable by sys admins, and not users" state, so I have to make it useable for the user.

The program is basically in two parts. A server and a GUI. The script takes arguments, and based on these arguments, will export some environment variables, kick off the server, then kick off the GUI.

Up until recently, this worked fine. However, I now need to run two back ends, and two GUI's. They communicate on dfiferent ports, and if I start everything up manually from the terminal, there is no problem. However, if I run the script twice, the second instance will kill the first instance. What I think is happening, is the 2nd server process is killing the first (and in turn, the GUI).

Since I can start two servers and two GUI's manually, all fingers are pointing to my script. I don't know too much about kicking off multiple system calls from a single perl script (like if it's a good or bad idea) so I'm a bit at a loss. Any help is appreciated.

Here's a very dumbed down version of the code. It should suffice.

#!/usr/bin/perl use strict; use warnings; my $server = $ARGV[0]; my $client = $ARGV[1]; my $display = $ARGV[2]; my $variable = $ARGV[3]; $ENV{"DISPLAY"} = $display . ":0.0"; my $bin = "/usr/local/bin/"; my $port = "2222" . ( $variable + 1 ); $ENV{"PORT"} = $port; #Start the server my $server_path = $bin . $server; system "$server_path &"; sleep 2; # Start up the client my $client_path = $bin . $client; system "$client_path";