Click here to get back home

Net::SSH::Perl to connect to a remote server via a web page

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Net::SSH::Perl to connect to a remote server via a web page Christian Caron 08-30-2004
Posted by Christian Caron on August 30, 2004, 10:02 am
Please log in for more thread options
Hi,

I'm trying to use Net::SSH::Perl to connect to a remote server via a web
page. The webserver is running as an unprivileged user (webserve).

This code does work fine from the command line (as user webserve), but when
I try the same code from the web interface, it prints everything up to the
$ssh->cmd() line...

Is this a security feature? Any solution for something like this to work?

Thanks!

=============================================

Code:

---------------------------------------------

#!/usr/local/bin/perl

use Net::SSH::Perl;

use strict;

my $server = 'server';

my $un = 'username';

my $pw = 'password';

print "Content-type: text/htmlnn";

print "<html><body>n";

print "Testing Net::SSH::Perln";

my $ssh = Net::SSH::Perl->new("$server", port=>'22', protocol=>'1,2');

print "1...<br>";

$ssh->login($un, $pw);

print "2...<br>";

my ($stdout, $stderr, $exit) = $ssh->cmd("ls");

print "3...<br>";

print "stdout is $stdout<br>n";

print "stderr is $stderr<br>n";

print "exit is $exitn";

print "</body></html>";

=============================================



=============================================

Output from command line:

---------------------------------------------

name# perl x.cgi

Content-type: text/html

<html><body>

Testing Net::SSH::Perl

1...<br>2...<br>3...<br>stdout is CSSdomain_01.sql

check_version_unix.cgi

list

manic

public_html

reindex

scripts

test

<br>

stderr is <br>

exit is 0

</body></html>

=============================================



=============================================

Output from web page (source):

---------------------------------------------

<html><body>

Testing Net::SSH::Perl

1...<br>2...<br>

=============================================




Similar ThreadsPosted
Using Net::Telnet to connect to Perl server January 22, 2005, 12:57 am
Is there a module that grabs a remote page and prints thumbnail image? May 26, 2006, 12:09 am
Remote.pm (File::Remote) error handling question January 29, 2007, 12:57 pm
Sending "page up" and "page down" character problem. September 7, 2004, 1:59 pm
Remote.pm (File::Remote) problem February 28, 2006, 9:50 pm
Remote install of Perl Module April 12, 2005, 10:47 am
Error In Using Perl To Connect To MySQL May 27, 2006, 2:59 am
Starting a perl program when I connect to the internet. September 22, 2004, 3:34 pm
unable to connect to SuSE using net::ssh::perl module March 9, 2006, 10:23 pm
I want an perl module for conver large html page file to multi little pages November 14, 2004, 3:02 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap