Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use warnings;
- $| = 1;
- $pid = open (SSH,"| ssh user@host");
- if(defined($pid)){
- if(!$pid){
- #child
- while(<>){
- print;
- }
- }else{
- select SSH;
- $| = 1;
- select STDIN;
- #parent
- while(<>){
- print SSH $_;
- while(<SSH>){
- print;
- }
- }
- close(SSH);
- }
- }
- use strict; use warnings;
- my $pid = open my $SSH, '-|', 'ssh user@example.com' // die $!;
- if ($pid) {
- while( <$SSH> ) {
- print $_;
- }
- }
- else {
- while( <> ) {
- print $SSH $_;
- }
- }
- close $SSH or die $!;
- use Net::OpenSSH;
- my $ssh = Net::OpenSSH->new($host, user => $user, password => $password);
- my ($in, $out, $pid) = $ssh->open2($remote_cmd);
- use IPC::Open2 qw(open2);
- my $pid = open2(my $in, my $out, $ssh_cmd);
Add Comment
Please, Sign In to add comment