line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XAS::Lib::SSH::Client::Subsystem; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use XAS::Class |
6
|
1
|
|
|
|
|
5
|
debug => 0, |
7
|
|
|
|
|
|
|
version => $VERSION, |
8
|
|
|
|
|
|
|
base => 'XAS::Lib::SSH::Client', |
9
|
|
|
|
|
|
|
utils => ':validation trim', |
10
|
|
|
|
|
|
|
constants => 'CODEREF', |
11
|
1
|
|
|
1
|
|
634
|
; |
|
1
|
|
|
|
|
2
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#use Data::Hexdumper; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
16
|
|
|
|
|
|
|
# Public Methods |
17
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub setup { |
20
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
my $output; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Merge stderr and stdout. |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
$self->chan->ext_data('merge'); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub run { |
31
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
32
|
0
|
|
|
|
|
|
my ($subsystem) = validate_params(\@_, [1] ); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Invoke the subsystem. |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
$self->chan->pty('vt100'); # set up a default pty |
37
|
0
|
|
|
|
|
|
$self->chan->subsystem($subsystem); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# flush the buffers |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
$self->puts(""); |
42
|
0
|
|
|
|
|
|
$self->gets(); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub call { |
47
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
48
|
0
|
|
|
|
|
|
my ($command, $parser) = validate_params(\@_, [ |
49
|
|
|
|
|
|
|
1, |
50
|
|
|
|
|
|
|
{ type => CODEREF }, |
51
|
|
|
|
|
|
|
]); |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
my @output; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# execute a command, retrieve the output and dispatch to a parser. |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
$self->puts($command); |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
do { |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
my $line = $self->gets; |
62
|
0
|
|
|
|
|
|
push(@output, $line); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
} while ($self->pending); |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
return $parser->(\@output); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
71
|
|
|
|
|
|
|
# Private Methods |
72
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |