This repository has been archived by the owner on Jun 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.pl
247 lines (221 loc) · 5.15 KB
/
menu.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
#!/usr/bin/perl -w
####################################
# BSD 3-Clause License
#Copyright (c) 2021, M.Konstantinovna
#All rights reserved.
#####################################
use strict;
use warnings;
sub menu()
{
my ( $msg ) = <<'H';
_|_
|
|
)6(
|☦|
☦ _+|_|+_ ☦
)6( |:|:|:| )6(
| |_||H|H||_| |
, | |:|:|:|:|:| | ,
)X(_+_| ||H|A|X|A|| |_+_)H(
|P| | | H A O T I K | | |A|
|E|:|:| |:|:|:|:|:| |:|:|O|
|R||H|| ||A|O|T|I|| ||K||T|
|L|:|:| |:|:|:|:|:| |:|:|I|
|_||H||_||H|===|H||_||H||K|
^^" ~^^/ /^^~ "^^~
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
You summoning Haotik!
what do u need?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1. Show interface.
2. Show ip address.
3. Show log.
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
4. Check beep.
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
5. Configure Mikrotik.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
H
my ( $menu ) = <<'A';
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1. Show interface.
2. Show ip address.
3. Show log.
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
4. Check beep.
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
5. Configure Mikrotik!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A
my ( $msg0, $msg1, # interactive.
$msg2, $msg3, # Interactive.
$msg4, $msg5, # Reserved.
$msg6, $msg7, # Reserved.
$msg8, $msg9, # Reserved.
$msg_clear, # Screen and terminal clear.
$msg_space, # Multiline symbol null " " for Menu.
$msg_tilda, # Multiline symbol tilda "~" for Menu.
$msg_caret, # Multiline symbol caret "^" for Menu.
$msg_exc, # Multiline symbol exclamation "!" for Menu.
$msg_bye # Drop
);
( $msg_clear ) = qq([2J\033[H\033[J);
( $msg_space ) = q( ) x 13;
( $msg_tilda ) = q(~) x 46;
( $msg_caret ) = q(^) x 46;
( $msg_exc ) = q(+!) x 23;
( $msg_bye ) = q(Bye! ) x 10000;
( $msg0 ) = qq(\nSend me number: => );
( $msg1 ) = qq($msg_clear$msg_tilda\n\e[1;5;35m$msg_space SELECTED I\e[0m\n$msg_tilda);
( $msg2 ) = qq($msg_clear$msg_tilda\n\e[1;5;31m$msg_space SELECTED II\e[0m\n$msg_tilda);
( $msg3 ) = qq($msg_clear$msg_tilda\n\e[1;5;31m$msg_space SELECTED III\e[0m\n$msg_tilda);
( $msg4 ) = qq($msg_clear$msg_tilda\n\e[1;5;31m$msg_space SELECTED IV\e[0m\n$msg_tilda);
( $msg5 ) = qq($msg_clear$msg_tilda\n\e[1;5;31m$msg_space SELECTED V\e[0m\n$msg_tilda);
print $msg;
while (1)
{
print $msg0;
my $query = <<>>;
chomp($query);
# Separation selected menu.
if ($query eq "1")
{
printf($msg1);
}
elsif ($query eq "2")
{
printf($msg2);
}
elsif ($query eq "3")
{
printf($msg3);
}
elsif ($query eq "4")
{
printf($msg4);
&ssh_beep,
printf($msg_clear),
printf($menu);
}
elsif ($query eq "5")
{
printf($msg5);
&config_menu;
}
else
{
print($msg_bye),
exit;
}
}
};
sub ssh_beep
{
use Net::OpenSSH;
my ( $name, $addr, $pass, $off, $beep, $get );
( $name ) = qq(YOU_LOGIN);
( $addr ) = qq(YOU_IP);
( $pass ) = "YOU_PASS";
( $off ) = int(7);
( $get ) = Net::OpenSSH->new
(
$addr,
user => $name,
password => $pass,
timeout => $off,
master_opts => [ -o => "StrictHostKeyChecking=no" ]
);
( $beep ) = ("beep frequency=10101 length=0.1");
( $get )->capture( $beep ) or die "I want c0ff33";
};
sub config_menu
{
my ( $msg0 ) = qq(\nSend me number: => );
my ( $dead ) = qq(\nY0u selected invalid number: );
my ( $msg_clear ) = qq([2J\033[H\033[J);
my ( $menu_config ) = <<'X';
1. Configure ip address.
+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!
0. Return menu.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X
printf("\n".$menu_config);
while (1)
{
print $msg0;
my $query = <<>>;
chomp($query);
if ($query eq "1")
{
printf($msg_clear);
&show_ip;
&config_ip;
}
elsif ($query eq "0")
{
return &menu;
}
else
{
return &menu;
}
}
};
sub show_ip
{
use Net::OpenSSH;
my ( $name, $addr, $pass, $off, $sh_ip, $get );
( $name ) = qq(YOU_LOGIN);
( $addr ) = qq(YOU_IP);
( $pass ) = "YOU_PASS";
( $off ) = int(7);
( $get ) = Net::OpenSSH->new
(
$addr,
user => $name,
password => $pass,
timeout => $off,
master_opts => [ -o => "StrictHostKeyChecking=no" ]
);
( $sh_ip ) = ("ip address print brief");
my $anchor = ( $get )->capture( $sh_ip ); printf($anchor)
or die "I want c0ff33 and sub show_ip";
};
sub config_ip
{
my ( $msg0 ) = qq(\nSend me number: => );
my ( $msg1 ) = qq(\nSend me ip address: => );
my ( $msg2 ) = qq(Send me interface: => );
my ( $msg_tilda ) = q(~) x 46;
my ( $msg_tipa ) = ($msg_tilda.$msg1);
my ( $menu_config_1 ) = <<'configure_ip';
+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!
1. Add ip address.
0. Return configure menu.
+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!
configure_ip
printf($menu_config_1);
while (1)
{
printf($msg0),
chomp( my $query = <<>> );
if ($query eq "1")
{
#use Net::OpenSSH;
printf($msg_tipa),
chomp( my $address = <<>> );
printf($msg2),
chomp( my $interface = <<>> );
printf("\nip address add address=$address interface=$interface\n".$msg_tilda."\n");
exit;
}
elsif ($query eq "0")
{
&config_menu;
}
}
};
&menu
__END__