We help IT Professionals succeed at work.

perl system command never returns

koppcha
koppcha asked
on
Hi,
  I have web page in which i need to run per script(#1) on a given host. I am using Net::SSH::Perl to run the script on the host.
  perl script #1 calls perl script #2(which is a Daemon process running the background. This program will come back immediately when i run it from the command prompt) using system function. This system function never returns it call the Daemon process and it never returns. Any idea what could be the reason.








Inside Web page

my $ssh = new Net::SSH::Perl($hostname);
$ssh->login( "user", "passwd" );
my $cmd  = "/home/xxx/server_admin.pl START STAGE";
my ( $stdout, $stderr, $exit ) = $ssh->cmd($cmd);
print "Done Running" ###It never gets to this point

sever_admin.pl
eval {
   my $directory = "/home/yyy/FP/bin";
   chdir($directory);
   my $cmd = "./server.pl FeedConfig_STAGE.txt start";
   system($cmd); ##This command never returns
};
if($@) {
     print {*STDERR} "Unable to start Feed Process Server: ". $@;
     exit 1;
}


server.pl -->This is a Daemon process that runs in the background.
use strict;
use warnings;
use App::Daemon qw(daemonize);
$App::Daemon::logfile = $ENV{SERVER_LOG};
$App::Daemon::pidfile = $ENV{PID_FILE};
/*
all usefull stuff
*/

Open in new window

Comment
Watch Question

Most Valuable Expert 2014
Top Expert 2015
Commented:
try
system("$cmd &");
or see
perldoc -q background

Author

Commented:
"cmd &" didn't work. But i re-directed the STDOUT and STDERR which helped.