#!/usr/bin/perl -w use Net::SSH qw(sshopen2); $host="myhost.somedomain.org"; check_release($host,"/etc/redhat-release"); sub check_release { my ($myhostname,$myfile)=@_; my $user = "root"; my $cmd = "cat $myfile"; sshopen2("$user\@$myhostname", *READER, *WRITER, "$cmd") || die "ssh: $!"; while () { my $out = $_; if ($out =~ /.*5.*/) { print "RHEL 5\n"; } elsif ($out =~ /.*4.*/) { print "RHEL 4\n"; } } close(READER); close(WRITER); }