premal has asked for the wisdom of the Perl Monks concerning the following question:
Hi I have written a CGI Perl script which calls another Perl script (mytask.pl) using some parameters passed to it. Based on the parameters Mytask.pl decides which Operating System is used. In Mytask.pl has nested if-else for different tasks. It works fine for Windows and AIX using telent. For Linux I have used Net::SSH::W32Perl. When I run Mytask.pl from DOS command prompt and pass arguments manually it works fine but when I use CGI perl script it fails for the Module written for Linux. I have given the Linux module for the script below.
if ($ARGV[2] eq "Linux") { my $file = "C:\\Bounce\\$ARGV[0].txt"; open(INFO, ">$file"); print INFO "$ARGV[0]\n"; print INFO "$ARGV[3]\n"; print INFO "$ARGV[1]\n"; #Script executes fine upto this line. #From this line onwards it is not excuted and jumps to sleep (5) and e +xits; my $host = "$ARGV[0].domain.com"; my $user = "username"; my $pass = "password"; my $cmd = "cd $ARGV[3] && ./startServer.sh $ARGV[1]"; my $ssh = Net::SSH::W32Perl->new( $host, protocol => 2 ); $ssh->login($user, $pass); my($stdout, $stderr, $exit) = $ssh->cmd($cmd); #print $stdout, "\n"; print INFO $stdout; close(INFO); sleep (5); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net::SSH::W32Perl is not working with CGI Perl script
by Anonymous Monk on Mar 22, 2012 at 10:21 UTC |