in reply to Perl Script to Test Telnet Connectivity
This will do what you have requested: Connect via TCP and receive the first message sent form the server (which is the 'SSH-2.0-OpenSSH_7.4' you are after):
use IO::Socket::INET; # Connect to TCP socket my $socket = new IO::Socket::INET( PeerHost => '10.0.0.1', PeerPort => '1234', Proto => 'tcp', Timeout => 3 ); if ($socket) { # We are connected... my $buffer = ""; my $length = 1024; $socket->recv($buffer, $length); $socket->close(); print "OK - got message '$buffer'"; } else { # Connection failed print "Failed"; }
In Section
Seekers of Perl Wisdom