dru145 has asked for the wisdom of the Perl Monks concerning the following question:
Hey Monks,
I'm fairly new to Perl, so please excuse my stupidity. I can get the Net::SSH module working properly with the while loop, but I want to throw in a if..else statement, but I'm lost.
Also, what are the functions of the READER and WRITER commands in this script?
Thanks -Dru
#!/usr/bin/perl use Net::SSH qw(sshopen2); use strict; my $user = "jdoe"; my $host = "192.168.2.3"; my $cmd = "ps -ef | grep -v grep |grep fwd"; sshopen2("$user\@$host", *READER, *WRITER, $cmd) || die "ssh: +$!"; # Example from README # # while (<READER>) { # chomp(); # print "$_\n"; # } if ($cmd) { print "FWD is running\n"; } else { print "FWD is not running!!\n"; } close(READER); close(WRITER);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help with Net::SSH
by btrott (Parson) on May 31, 2001 at 21:53 UTC | |
by dru145 (Friar) on Jun 01, 2001 at 00:27 UTC | |
by btrott (Parson) on Jun 01, 2001 at 00:31 UTC | |
|
Re: Help with Net::SSH
by Anonymous Monk on May 31, 2001 at 21:10 UTC |