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); }

In reply to Net::SSH::W32Perl is not working with CGI Perl script by premal

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.