line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Jan Gehring |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Rex::Interface::Shell; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
14
|
use v5.12.5; |
|
1
|
|
|
|
|
4
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.14.2.2'; # TRIAL VERSION |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
5
|
use Rex::Logger; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my %SHELL_PROVIDER = ( |
15
|
|
|
|
|
|
|
ash => "Rex::Interface::Shell::Ash", |
16
|
|
|
|
|
|
|
bash => "Rex::Interface::Shell::Bash", |
17
|
|
|
|
|
|
|
csh => "Rex::Interface::Shell::Csh", |
18
|
|
|
|
|
|
|
idrac => "Rex::Interface::Shell::Idrac", |
19
|
|
|
|
|
|
|
ksh => "Rex::Interface::Shell::Ksh", |
20
|
|
|
|
|
|
|
sh => "Rex::Interface::Shell::Sh", |
21
|
|
|
|
|
|
|
tcsh => "Rex::Interface::Shell::Tcsh", |
22
|
|
|
|
|
|
|
zsh => "Rex::Interface::Shell::Zsh", |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub register_shell_provider { |
26
|
0
|
|
|
0
|
0
|
|
my ( $class, $shell_name, $shell_class ) = @_; |
27
|
0
|
|
|
|
|
|
$SHELL_PROVIDER{"\L$shell_name"} = $shell_class; |
28
|
0
|
|
|
|
|
|
return 1; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub get_shell_provider { |
32
|
0
|
|
|
0
|
0
|
|
return %SHELL_PROVIDER; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub create { |
36
|
0
|
|
|
0
|
0
|
|
my ( $class, $shell ) = @_; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
$shell =~ s/[\r\n]//gms; # sometimes there are some wired things... |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my $klass = "Rex::Interface::Shell::\u$shell"; |
41
|
0
|
|
|
|
|
|
eval "use $klass"; |
42
|
0
|
0
|
|
|
|
|
if ($@) { |
43
|
0
|
|
|
|
|
|
Rex::Logger::info( |
44
|
|
|
|
|
|
|
"Can't load wanted shell: '$shell' ('$klass'). Using default shell.", |
45
|
|
|
|
|
|
|
"warn" ); |
46
|
0
|
|
|
|
|
|
Rex::Logger::info( |
47
|
|
|
|
|
|
|
"If you want to help the development of Rex please report this issue in our Github issue tracker.", |
48
|
|
|
|
|
|
|
"warn" |
49
|
|
|
|
|
|
|
); |
50
|
0
|
|
|
|
|
|
$klass = "Rex::Interface::Shell::Default"; |
51
|
0
|
|
|
|
|
|
eval "use $klass"; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
return $klass->new; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |