Ben,

Thank you so much for your advice. It worked like a charm. I have been
beating myself up over this for a week and had I known it was so easy I
would have been done in a few minutes.

You and everyone else that replied have my sincere gratitude. 

Thanks again,

Greg Evans
Hood Canal Communications
(360) 898-2481 ext.212 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
BenRifkah Bergsten-Buret
Sent: Tuesday, May 13, 2008 11:49 AM
To: Greg Evans
Cc: mason-users@lists.sourceforge.net
Subject: Re: [Mason] Script not returning result within the mason
environment

The Mason elements of the script appear to be in order.  I have a feeling
the problem is in the way you're using Net::SSH.
Unfortunately, I don't have any experience with Net::SSH and the Net::SSH
documentation on CPAN is pretty sparse.

On Tue, May 13, 2008 at 10:20 AM, Greg Evans <[EMAIL PROTECTED]> wrote:
>  sshopen2('root@<my_ip>', *READER, *WRITER, $command) ||die "UNABLE TO
>
> ESTABLISH CONNECTION!: $!";

There are a few of ways in which this call could fail.  In any case I would
have expected the author of Net::SSH to cause the sshopen2 call to return a
non-true value and trigger your die statement.

However, Net::SSH uses the underlying ssh command installed on your system.
There are a couple of situations where ssh waits for user input.  It's
possible that this waiting is relayed by Net::SSH and its waiting for you to
provide input on the *WRITER file handle.  Since you mentioned that you have
tried running the script as the web server user it doesn't seem likely that
either** of these is causing your problem.

Its still likely that the call to sshopen2 isn't going as expected.  I
noticed that the sshopen2 call doesn't provide a handle for STDERR of the
ssh process and the documentation doesn't say where this should go.  If you
haven't already, check your apache error log for messages from the
underlying ssh process.  If you don't find anything it's possible that
Net::SSH isn't relaying messages properly.

Try replacing the Net::SSH code with a simple backticks system call:

<%perl>
my @output = `ssh root@<my_ip> ping -c1 $pingserver 2>&1`; $m->print(join
'<br />', "Here it is: ", @output, "There it was"); </%perl>

This will attempt to do pretty much the same thing as above, but the STDERR
of the ssh process will be captured in @output along with STDOUT.  If it
works then the problem is probably somewhere within Net::SSH.  If not you
may get an important message that is getting lost somewhere by the Net::SSH
version.

-- Ben

** One such situation is that you don't have SSH key's properly installed
for the user that is running your web server.  In this case Net::SSH could
be waiting for you to provide a password on *WRITER.

The second situation is when the webserver user has never before negotiated
an SSH connection with the server at <my_ip>.  In this situation ssh usually
asks if you wan't to accept the server key.  In this situation it might wait
for you to say "yes" on the *WRITER handle.


P.P.S.: I wouldn't allow ssh access to root on any of your servers.
Some people think that this restriction is merely an attempt at security
through obscurity, however it requires anyone who wants to infiltrate your
system to do more work to cover their tracks giving them more opportunities
to get caught.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to