i have a script that works great from the command line, but it fails at the call to cmd when run from the cgi...any idea why that might be?

here is the script (i know there are easier ways to get directory listings, but this is just a sublime example of what i am really trying to accomplish):

#!/usr/bin/perl use Net::SSH::Perl; use strict; print(qq(Content-Type: text/html\n\n)); print(qq(<HTML><HEAD><TITLE>Remote Test</TITLE></HEAD><BODY>)); &list_directory(); print(qq(</BODY></HTML>)); exit; sub list_directory { my(%ssh_params) = ( 'port' => '40001', ); my($hostname) = '12.345.67.890'; my($ssh_username) = 'root'; my($ssh_password) = 'noneya'; my($command) = qq(ls -l); print(qq(creating ssh connection<br>\n)); my($ssh) = Net::SSH::Perl->new($hostname), %ssh_params); print(qq(logging in<br>\n)); $ssh->login($ssh_username, $ssh_password); print(qq(running command: $command<br>\n)); my($stdout, $stderr, $exitval) = $ssh->cmd($command); print(qq(directory listing: $stdout<br>\n)); } 1;
when run from the shell (as the web server user), it works great (a.k.a. i get a directory listing) but when run via the web browser it says it is going to run the command but i get no output

i thought it might be something with the default port (22) not being accessible from the web, which is why i started sshd on another port (40001) and used the port option to access it that way, but still no luck

my guess is that it is a permissions issue (isn't it always?) but i am not sure how to ferret it out beyond what i have already done


In reply to Net::SSH::Perl shell vs web by mikihasa

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.