1Rex::Helper::SSH2::ExpeUcste(r3)Contributed Perl DocumenRteaxt:i:oHnelper::SSH2::Expect(3)
2
3
4

NAME

6       Rex::Helper::SSH2::Expect - An Expect like module for Net::SSH2
7

DESCRIPTION

9       This is a module to have expect like features for Net::SSH2. This is
10       the first version of this module. Please report bugs at GitHub
11       <https://github.com/krimdomu/net-ssh2-expect>
12

DEPENDENCIES

14       •   Net::SSH2
15

SYNOPSIS

17        use Rex::Helper::SSH2::Expect;
18
19        my $exp = Rex::Helper::SSH2::Expect->new($ssh2);
20        $exp->spawn("passwd");
21        $exp->expect($timeout, [
22                         qr/Enter new UNIX password:/ => sub {
23                                                 my ($exp, $line) = @_;
24                                                 $exp->send($new_password);
25                                               }
26                       ],
27                       [
28                         qr/Retype new UNIX password:/ => sub {
29                                                 my ($exp, $line) = @_;
30                                                 $exp->send($new_password);
31                                               }
32                       ],
33                       [
34                         qr/passwd: password updated successfully/ => sub {
35                                                         my ($exp, $line) = @_;
36                                                         $exp->hard_close;
37                                                       }
38                       ]);
39

CLASS METHODS

41   new($ssh2)
42       Constructor: You need to parse an connected Net::SSH2 Object.
43
44   log_stdout(0|1)
45       Log on STDOUT.
46
47   log_file($file)
48       Log everything to a file. $file can be a filename, a filehandle or a
49       subRef.
50
51   spawn($command, @parameters)
52       Spawn $command with @parameters as parameters.
53
54   soft_close()
55       Currently only an alias to hard_close();
56
57   hard_close();
58       Stops the execution of the process.
59
60   expect($timeout, @match_patters)
61       This method controls the execution of your process.
62
63   send($string)
64       Send a string to the running command.
65
66
67
68perl v5.36.1                      2023-08-07      Rex::Helper::SSH2::Expect(3)
Impressum