package Net::SSH;
use strict;
-use vars qw($VERSION @ISA @EXPORT_OK $ssh $DEBUG);
+use vars qw($VERSION @ISA @EXPORT_OK $ssh $equalspace $DEBUG);
use Exporter;
use IO::File;
use IPC::Open2;
@ISA = qw(Exporter);
@EXPORT_OK = qw( ssh issh ssh_cmd sshopen2 sshopen3 );
-$VERSION = '0.05';
+$VERSION = '0.06';
$DEBUG = 0;
$ssh = "ssh";
+my $reader = IO::File->new();
+my $writer = IO::File->new();
+my $error = IO::File->new();
+open3($writer, $reader, $error, $ssh, '-V');
+my $ssh_version = <$error>;
+chomp($ssh_version);
+$ssh_version =~ s/.*OpenSSH[-|_](\w+?)\.\w+?\.\w+?.*/$1/g;
+if ($ssh_version == 1) {
+ $equalspace = " ";
+} else {
+ $equalspace = "=";
+}
+
=head1 NAME
Net::SSH - Perl extension for secure shell
sub ssh {
my($host, @command) = @_;
- my @cmd = ($ssh, '-o', 'BatchMode=yes', $host, @command);
+ my @cmd = ($ssh, '-o', 'BatchMode'.$equalspace.'yes', $host, @command);
warn "[Net::SSH::ssh] executing ". join(' ', @cmd). "\n"
if $DEBUG;
system(@cmd);
sub sshopen2 {
my($host, $reader, $writer, @command) = @_;
- open2($reader, $writer, $ssh, '-o', 'BatchMode=yes', $host, @command);
+ open2($reader, $writer, $ssh, '-o', 'BatchMode'.$equalspace.'yes', $host, @command);
}
=item sshopen3 HOST, WRITER, READER, ERROR, COMMAND [, ARGS ... ]
sub sshopen3 {
my($host, $writer, $reader, $error, @command) = @_;
- open3($writer, $reader, $error, $ssh, '-o', 'BatchMode=yes', $host, @command);
+ open3($writer, $reader, $error, $ssh, '-o', 'BatchMode'.$equalspace.'yes', $host, @command);
}
sub _yesno {
Martin Langhoff <martin@cwa.co.nz> contributed the ssh_cmd command, and
Jeff Finucane <jeff@cmh.net> updated it and took care of the 0.04 release.
+Anthony Awtrey <tony@awtrey.com> contributed a fix for those still using
+OpenSSH v1.
+
=head1 COPYRIGHT
Copyright (c) 2002 Ivan Kohler.