+=item ssh_cmd [USER@]HOST, COMMAND [, ARGS ... ]
+
+Calls ssh in batch mode. Dies if data occurs on the error stream. Warns
+of data on the output stream.
+
+=cut
+
+sub ssh_cmd {
+ my($host, @command) = @_;
+
+ my $reader = IO::File->new();
+ my $writer = IO::File->new();
+ my $error = IO::File->new();
+
+ sshopen3( $host, $reader, $writer, $error, @command ) or die $!;
+
+ local $/ = undef;
+ my $output_stream = <$writer>;
+ my $error_stream = <$error>;
+ if ( length $error_stream ) {
+ die "[Net:SSH::ssh_cmd] STDERR $error_stream";
+ }
+ if ( length $output_stream ) {
+ warn "[Net::SSH::ssh_cmd] STDOUT $output_stream";
+ }
+
+}
+