Thread Net::OpenSSH > nachfolgende, abhängige Kommandos (11 answers)
Opened by Martin at 2013-09-19 18:32

Gast salva
 2013-09-23 12:20
#170513 #170513
Running a shell is easy:

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
my $ssh = Net::OpenSSH->new(...);
my ($in, $out, $pid) = $ssh->open2(); # passing no cmd will start a shell
print {$in} "ls\n";
while (<$out>) {
  print "out: $_";
  last if /$prompt_re/;
}
print {$in} "pwd\n";
...


Sometimes the following also works:

Code (perl): (dl )
1
2
my $out = $ssh->capture({stdin_data => 'ls\npwd\n'});
print "output:\n$out";

Last edited: 2013-09-23 12:26:53 +0200 (CEST)

View full thread Net::OpenSSH > nachfolgende, abhängige Kommandos