Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NET::SSH:Perl question.

Status
Not open for further replies.

nawlej

Programmer
Mar 26, 2004
380
US
I am writing a script which requires me to test servers for listening SSH ports and push the working hostnames into an array. I decided on using NET:SSH:perl for this task, because our firewall blocks both Telnet and Ping requests, so I am stuck using an actual SSH connection to see if the port is listening. Has anyone successfully accomplished this? Bascally, I figure I am going to have to attempt a new connection, but can I just do something like:

foreach $host (@hosts){
$cnx = NET::SSH:perl->new($host);

if($cnx){
push (@working, $host);
}
$cnx->close;
}

I guess my main question would be, would that if statement actually validate a working connection or not??

Please help. Any and all is appreciated.

-Eric
 
depends on what Net::SSH returns as the value for the connection

All you can really do is test it against machines running SSH, and other machines not running the daemon


HTH
--Paul
 
If the server isnt running the SSH daemon, shouldnt the connection attempt time out, and make the variable null though?
 
I'd have thought the value for a timeout when returned would be different to success


Don't have an SSH server to test against

Sorry
--Paul
 
Thank you anyway :) Can anyone else help?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top