rev |
line source |
devi@23
|
1 #!/usr/bin/perl -w
|
devi@23
|
2
|
devi@31
|
3 use IO::Socket;
|
devi@23
|
4 use lib '.';
|
devi@23
|
5 use l3config;
|
devi@31
|
6 use locale;
|
devi@23
|
7
|
devi@23
|
8 our @Command_Lines;
|
devi@31
|
9 our @Command_Lines_Index;
|
devi@31
|
10 our %Commands_Description;
|
devi@31
|
11 our %Args_Description;
|
devi@31
|
12 our $Mywi_Socket;
|
devi@32
|
13 our %Sessions;
|
devi@23
|
14
|
devi@23
|
15 # vvv Инициализация переменных выполняется процедурой init_variables
|
devi@23
|
16 our @Day_Name;
|
devi@23
|
17 our @Month_Name;
|
devi@23
|
18 our @Of_Month_Name;
|
devi@23
|
19 our %Search_Machines;
|
devi@23
|
20 our %Elements_Visibility;
|
devi@23
|
21 # ^^^
|
devi@23
|
22
|
devi@31
|
23 our %Stat;
|
devi@31
|
24 our %CommandsFDistribution; # Сколько раз в журнале встречается какая команда
|
devi@31
|
25
|
devi@23
|
26 sub search_buy;
|
devi@23
|
27 sub make_comment;
|
devi@23
|
28 sub load_command_lines_from_xml;
|
devi@32
|
29 sub load_sessions_from_xml;
|
devi@23
|
30 sub print_command_lines;
|
devi@31
|
31 sub sort_command_lines;
|
devi@31
|
32 sub process_command_lines;
|
devi@23
|
33 sub init_variables;
|
devi@23
|
34 sub main;
|
devi@31
|
35 sub collapse_list($);
|
devi@23
|
36
|
devi@23
|
37 main();
|
devi@23
|
38
|
devi@23
|
39 sub main
|
devi@23
|
40 {
|
devi@23
|
41 $| = 1;
|
devi@23
|
42
|
devi@23
|
43 init_variables();
|
devi@23
|
44 init_config();
|
devi@23
|
45
|
devi@32
|
46 open_mywi_socket();
|
devi@27
|
47 load_command_lines_from_xml($Config{"backend_datafile"});
|
devi@32
|
48 load_sessions_from_xml($Config{"backend_datafile"});
|
devi@31
|
49 sort_command_lines;
|
devi@31
|
50 process_command_lines;
|
devi@23
|
51 print_command_lines($Config{"output"});
|
devi@31
|
52 close_mywi_socket;
|
devi@23
|
53 }
|
devi@23
|
54
|
devi@23
|
55
|
devi@23
|
56 sub search_by
|
devi@23
|
57 {
|
devi@23
|
58 my $sm = shift;
|
devi@23
|
59 my $topic = shift;
|
devi@23
|
60 $topic =~ s/ /+/;
|
devi@23
|
61
|
devi@23
|
62 return "<a href='". $Search_Machines{$sm}->{"query"}."$topic'><img width='16' height='16' src='".
|
devi@23
|
63 $Search_Machines{$sm}->{"icon"}."' border='0'/></a>";
|
devi@23
|
64 }
|
devi@23
|
65
|
devi@31
|
66 sub extract_from_cline
|
devi@31
|
67 # Разобрать командную строку $_[1] и возвратить хэш, содержащий
|
devi@31
|
68 # номер первого появление команды в строке:
|
devi@31
|
69 # команда => первая позиция
|
devi@31
|
70 {
|
devi@31
|
71 my $what = $_[0];
|
devi@31
|
72 my $cline = $_[1];
|
devi@31
|
73 my @lists = split /\;/, $cline;
|
devi@31
|
74
|
devi@31
|
75
|
devi@31
|
76 my @commands = ();
|
devi@31
|
77 for my $list (@lists) {
|
devi@31
|
78 push @commands, split /\|/, $list;
|
devi@31
|
79 }
|
devi@31
|
80
|
devi@31
|
81 my %commands;
|
devi@31
|
82 my %args;
|
devi@31
|
83 my $i=0;
|
devi@31
|
84 for my $command (@commands) {
|
devi@31
|
85 $command =~ s@^\s*\S+/@@;
|
devi@31
|
86 $command =~ /\s*(\S+)\s*(.*)/;
|
devi@31
|
87 if ($1 && $1 eq "sudo" ) {
|
devi@31
|
88 $commands{"$1"}=$i++;
|
devi@31
|
89 $command =~ s/\s*sudo\s+//;
|
devi@31
|
90 }
|
devi@31
|
91 $command =~ s@^\s*\S+/@@;
|
devi@31
|
92 $command =~ /\s*(\S+)\s*(.*)/;
|
devi@31
|
93 if ($1 && !defined $commands{"$1"}) {
|
devi@31
|
94 $commands{"$1"}=$i++;
|
devi@31
|
95 };
|
devi@31
|
96 if ($2) {
|
devi@31
|
97 my $args = $2;
|
devi@31
|
98 my @args = split (/\s+/, $args);
|
devi@31
|
99 for my $a (@args) {
|
devi@31
|
100 $args{"$a"}=$i++
|
devi@31
|
101 if !defined $args{"$a"};
|
devi@31
|
102 };
|
devi@31
|
103
|
devi@31
|
104
|
devi@31
|
105 }
|
devi@31
|
106 }
|
devi@31
|
107
|
devi@31
|
108 if ($what eq "commands") {
|
devi@31
|
109 return \%commands;
|
devi@31
|
110 } else {
|
devi@31
|
111 return \%args;
|
devi@31
|
112 }
|
devi@31
|
113
|
devi@31
|
114 }
|
devi@31
|
115
|
devi@31
|
116 sub open_mywi_socket
|
devi@31
|
117 {
|
devi@31
|
118 $Mywi_Socket = IO::Socket::INET->new(
|
devi@31
|
119 PeerAddr => $Config{mywi_server},
|
devi@31
|
120 PeerPort => $Config{mywi_port},
|
devi@31
|
121 Proto => "tcp",
|
devi@31
|
122 Type => SOCK_STREAM);
|
devi@31
|
123 }
|
devi@31
|
124
|
devi@31
|
125 sub close_mywi_socket
|
devi@31
|
126 {
|
devi@31
|
127 close ($Mywi_Socket);
|
devi@31
|
128 }
|
devi@31
|
129
|
devi@31
|
130
|
devi@31
|
131 sub mywi_client
|
devi@31
|
132 {
|
devi@31
|
133 my $query = $_[0];
|
devi@31
|
134 my $mywi;
|
devi@31
|
135
|
devi@31
|
136 open_mywi_socket;
|
devi@31
|
137 if ($Mywi_Socket) {
|
devi@31
|
138 local $| = 1;
|
devi@31
|
139 local $/ = "";
|
devi@31
|
140 print $Mywi_Socket $query."\n";
|
devi@31
|
141 $mywi = <$Mywi_Socket>;
|
devi@31
|
142 $mywi = "" if $mywi =~ /nothing app/;
|
devi@31
|
143 }
|
devi@31
|
144 close_mywi_socket;
|
devi@31
|
145 return $mywi;
|
devi@31
|
146 }
|
devi@31
|
147
|
devi@23
|
148 sub make_comment
|
devi@23
|
149 {
|
devi@31
|
150 my $cline = $_[0];
|
devi@31
|
151 #my $files = $_[1];
|
devi@23
|
152
|
devi@31
|
153 my @comments=();
|
devi@31
|
154 my @commands = keys %{extract_from_cline("commands", $cline)};
|
devi@31
|
155 my @args = keys %{extract_from_cline("args", $cline)};
|
devi@31
|
156 return if (!@commands && !@args);
|
devi@31
|
157 #return "commands=".join(" ",@commands)."; files=".join(" ",@files);
|
devi@23
|
158
|
devi@23
|
159 # Commands
|
devi@31
|
160 for my $command (@commands) {
|
devi@23
|
161 $command =~ s/'//g;
|
devi@31
|
162 $CommandsFDistribution{$command}++;
|
devi@31
|
163 if (!$Commands_Description{$command}) {
|
devi@35
|
164 my $mywi="";
|
devi@31
|
165 $mywi = mywi_client ($command);
|
devi@31
|
166 $mywi = join ("\n", grep(/\([18]\)/, split(/\n/, $mywi)));
|
devi@31
|
167 $mywi =~ s/\s+/ /;
|
devi@31
|
168 if ($mywi !~ /^\s*$/) {
|
devi@31
|
169 $Commands_Description{$command} = $mywi;
|
devi@31
|
170 }
|
devi@31
|
171 else {
|
devi@31
|
172 next;
|
devi@31
|
173 }
|
devi@31
|
174 }
|
devi@23
|
175
|
devi@31
|
176 push @comments, $Commands_Description{$command};
|
devi@23
|
177 }
|
devi@31
|
178 return join(" \n", @comments);
|
devi@23
|
179
|
devi@23
|
180 # Files
|
devi@31
|
181 for my $arg (@args) {
|
devi@31
|
182 $arg =~ s/'//g;
|
devi@31
|
183 if (!$Args_Description{$arg}) {
|
devi@31
|
184 my $mywi;
|
devi@31
|
185 $mywi = mywi_client ($arg);
|
devi@31
|
186 $mywi = join ("\n", grep(/\([5]\)/, split(/\n/, $mywi)));
|
devi@31
|
187 $mywi =~ s/\s+/ /;
|
devi@31
|
188 if ($mywi !~ /^\s*$/) {
|
devi@31
|
189 $Args_Description{$arg} = $mywi;
|
devi@31
|
190 }
|
devi@31
|
191 else {
|
devi@31
|
192 next;
|
devi@31
|
193 }
|
devi@31
|
194 }
|
devi@23
|
195
|
devi@31
|
196 push @comments, $Args_Description{$arg};
|
devi@23
|
197 }
|
devi@23
|
198
|
devi@23
|
199 }
|
devi@23
|
200
|
devi@23
|
201 =cut
|
devi@23
|
202 Процедура load_command_lines_from_xml выполняет загрузку разобранного lab-скрипта
|
devi@23
|
203 из XML-документа в переменную @Command_Lines
|
devi@23
|
204
|
devi@23
|
205 Предупреждение!
|
devi@23
|
206 Процедура не в состоянии обрабатывать XML-документ любой структуры.
|
devi@23
|
207 В действительности файл cache из которого загружаются данные
|
devi@23
|
208 просто напоминает XML с виду.
|
devi@23
|
209 =cut
|
devi@23
|
210 sub load_command_lines_from_xml
|
devi@23
|
211 {
|
devi@23
|
212 my $datafile = $_[0];
|
devi@23
|
213
|
devi@23
|
214 open (CLASS, $datafile)
|
devi@23
|
215 or die "Can't open file of the class ",$datafile,"\n";
|
devi@23
|
216 local $/;
|
devi@23
|
217 $data = <CLASS>;
|
devi@23
|
218 close(CLASS);
|
devi@23
|
219
|
devi@23
|
220 for $command ($data =~ m@<command>(.*?)</command>@sg) {
|
devi@23
|
221 my %cl;
|
devi@23
|
222 while ($command =~ m@<([^>]*?)>(.*?)</\1>@sg) {
|
devi@23
|
223 $cl{$1} = $2;
|
devi@23
|
224 }
|
devi@23
|
225 push @Command_Lines, \%cl;
|
devi@23
|
226 }
|
devi@23
|
227 }
|
devi@23
|
228
|
devi@32
|
229 sub load_sessions_from_xml
|
devi@32
|
230 {
|
devi@32
|
231 my $datafile = $_[0];
|
devi@32
|
232
|
devi@32
|
233 open (CLASS, $datafile)
|
devi@32
|
234 or die "Can't open file of the class ",$datafile,"\n";
|
devi@32
|
235 local $/;
|
devi@32
|
236 my $data = <CLASS>;
|
devi@32
|
237 close(CLASS);
|
devi@32
|
238
|
devi@32
|
239 for my $session ($data =~ m@<session>(.*?)</session>@sg) {
|
devi@32
|
240 my %session;
|
devi@32
|
241 while ($session =~ m@<([^>]*?)>(.*?)</\1>@sg) {
|
devi@32
|
242 $session{$1} = $2;
|
devi@32
|
243 }
|
devi@32
|
244 $Sessions{$session{local_session_id}} = \%session;
|
devi@32
|
245 }
|
devi@32
|
246 }
|
devi@32
|
247
|
devi@32
|
248
|
devi@32
|
249
|
devi@31
|
250 sub sort_command_lines
|
devi@31
|
251 {
|
devi@31
|
252 # Sort Command_Lines
|
devi@31
|
253 # Write Command_Lines to Command_Lines_Index
|
devi@31
|
254
|
devi@31
|
255 my @index;
|
devi@31
|
256 for (my $i=0;$i<=$#Command_Lines;$i++) {
|
devi@31
|
257 $index[$i]=$i;
|
devi@31
|
258 }
|
devi@31
|
259
|
devi@31
|
260 @Command_Lines_Index = sort {
|
devi@31
|
261 $Command_Lines[$index[$a]]->{"time"} <=> $Command_Lines[$index[$b]]->{"time"}
|
devi@31
|
262 } @index;
|
devi@31
|
263
|
devi@31
|
264 }
|
devi@31
|
265
|
devi@31
|
266 sub process_command_lines
|
devi@31
|
267 {
|
devi@31
|
268 for my $i (@Command_Lines_Index) {
|
devi@31
|
269
|
devi@31
|
270 my $cl = \$Command_Lines[$i];
|
devi@35
|
271 #@{${$cl}->{"new_commands"}} =();
|
devi@35
|
272 #@{${$cl}->{"new_files"}} =();
|
devi@31
|
273 $$cl->{"class"} = "";
|
devi@31
|
274
|
devi@31
|
275 if ($$cl->{"err"}) {
|
devi@31
|
276 $$cl->{"class"}="wrong";
|
devi@31
|
277 $$cl->{"class"}="interrupted"
|
devi@31
|
278 if ($$cl->{"err"} eq 130);
|
devi@31
|
279 }
|
devi@31
|
280 if (!$$cl->{"euid"}) {
|
devi@31
|
281 $$cl->{"class"}.="_root";
|
devi@31
|
282 }
|
devi@31
|
283
|
devi@31
|
284 #tab# my @tab_words=split /\s+/, $$cl->{"output"};
|
devi@31
|
285 #tab# my $last_word= $$cl->{"cline"} =~ /(\S*)$/;
|
devi@31
|
286 #tab# $last_word =~ s@.*/@@;
|
devi@31
|
287 #tab# my $this_is_tab=1;
|
devi@31
|
288 #tab#
|
devi@31
|
289 #tab# if ($last_word && @tab_words >2) {
|
devi@31
|
290 #tab# for my $tab_words (@tab_words) {
|
devi@31
|
291 #tab# if ($tab_words !~ /^$last_word/) {
|
devi@31
|
292 #tab# $this_is_tab=0;
|
devi@31
|
293 #tab# last;
|
devi@31
|
294 #tab# }
|
devi@31
|
295 #tab# }
|
devi@31
|
296 #tab# }
|
devi@31
|
297 #tab# $$cl->{"class"}="tab" if $this_is_tab;
|
devi@31
|
298
|
devi@31
|
299
|
devi@31
|
300 # if ( !$$cl->{"err"}) {
|
devi@31
|
301 # # Command does not contain mistakes
|
devi@31
|
302 #
|
devi@31
|
303 # my %commands = extract_from_cline("commands", ${$cl}->{"cline"});
|
devi@31
|
304 # my %files = extract_from_cline("files", ${$cl}->{"cline"});
|
devi@31
|
305 #
|
devi@31
|
306 # # Searching for new commands only
|
devi@31
|
307 # for my $command (keys %commands) {
|
devi@31
|
308 # if (!defined $Commands_Stat{$command}) {
|
devi@31
|
309 # push @{$$cl->{new_commands}}, $command;
|
devi@31
|
310 # }
|
devi@31
|
311 # $Commands_Stat{$command}++;
|
devi@31
|
312 # }
|
devi@31
|
313 #
|
devi@31
|
314 # for my $file (keys %files) {
|
devi@31
|
315 # if (!defined $Files_Stat{$file}) {
|
devi@31
|
316 # push @{$$cl->{new_files}}, $file;
|
devi@31
|
317 # }
|
devi@31
|
318 # $Files_Stat{$file}++;
|
devi@31
|
319 # }
|
devi@31
|
320 # }
|
devi@31
|
321
|
devi@31
|
322 if ($$cl->{cline}=~ m@cat[^#]*#([\^=v])\s*(.*)@) {
|
devi@31
|
323 if ($1 eq "=") {
|
devi@31
|
324 $$cl->{"class"} = "note";
|
devi@31
|
325 $$cl->{"note"} = $$cl->{"output"};
|
devi@31
|
326 $$cl->{"note_title"} = $2;
|
devi@31
|
327 }
|
devi@31
|
328 else {
|
devi@31
|
329 my $j = $i;
|
devi@31
|
330 if ($1 eq "^") {
|
devi@31
|
331 $j--;
|
devi@32
|
332 $j-- while ($j >=0 && (!$Command_Lines[$j] || $Command_Lines[$j]->{tty} ne $$cl->{tty}));
|
devi@31
|
333 }
|
devi@31
|
334 elsif ($1 eq "v") {
|
devi@31
|
335 $j++;
|
devi@32
|
336 $j++ while ($j <= @Command_Lines && (!$Command_Lines[$j] || $Command_Lines[$j]->{tty} ne $$cl->{tty}));
|
devi@31
|
337 }
|
devi@31
|
338 $Command_Lines[$j]->{note_title}="$2";
|
devi@31
|
339 $Command_Lines[$j]->{note}=$$cl->{output};
|
devi@31
|
340 $$cl=0;
|
devi@31
|
341 }
|
devi@31
|
342 }
|
devi@31
|
343 elsif ($$cl->{cline}=~ /#([\^=v])(.*)/) {
|
devi@31
|
344 if ($1 eq "=") {
|
devi@31
|
345 $$cl->{"class"} = "note";
|
devi@31
|
346 $$cl->{"note"} = $2;
|
devi@31
|
347 }
|
devi@31
|
348 else {
|
devi@31
|
349 my $j=$i;
|
devi@31
|
350 if ($1 eq "^") {
|
devi@31
|
351 $j--;
|
devi@31
|
352 $j-- while ($j >=0 && (!$Command_Lines[$j] || $Command_Lines[$j]->{tty} ne $$cl->{tty}));
|
devi@31
|
353 }
|
devi@31
|
354 elsif ($1 eq "v") {
|
devi@31
|
355 $j++;
|
devi@31
|
356 $j++ while ($j <= @Command_Lines && $Command_Lines[$j]->{tty} ne $$cl->{tty} || !$Command_Lines[$j]);
|
devi@31
|
357 }
|
devi@31
|
358 $Command_Lines[$j]->{note}="$2";
|
devi@31
|
359 $$cl=0;
|
devi@31
|
360 }
|
devi@31
|
361 }
|
devi@31
|
362 }
|
devi@31
|
363
|
devi@31
|
364 }
|
devi@31
|
365
|
devi@31
|
366
|
devi@23
|
367 =cut
|
devi@23
|
368 Процедура print_command_lines выводит HTML-представление
|
devi@23
|
369 разобранного lab-скрипта.
|
devi@23
|
370
|
devi@23
|
371 Разобранный lab-скрипт должен находиться в массиве @Command_Lines
|
devi@23
|
372 =cut
|
devi@23
|
373
|
devi@23
|
374 sub print_command_lines
|
devi@23
|
375 {
|
devi@23
|
376 my $output_filename=$_[0];
|
devi@23
|
377
|
devi@23
|
378 my $course_name = $Config{"course-name"};
|
devi@23
|
379 my $course_code = $Config{"course-code"};
|
devi@23
|
380 my $course_date = $Config{"course-date"};
|
devi@23
|
381 my $course_center = $Config{"course-center"};
|
devi@23
|
382 my $course_trainer = $Config{"course-trainer"};
|
devi@23
|
383 my $course_student = $Config{"course-student"};
|
devi@23
|
384
|
devi@23
|
385
|
devi@23
|
386 # Результат выполнения процедуры равен
|
devi@23
|
387 # join("", @Result{header,body,stat,help,about,footer})
|
devi@23
|
388 my %Result;
|
devi@31
|
389 my @toc; # Хранит оглавление
|
devi@31
|
390 my $note_number=0;
|
devi@23
|
391
|
devi@23
|
392 $Result{"body"} = "<table width='100%'>\n";
|
devi@23
|
393
|
devi@23
|
394 my $cl;
|
devi@23
|
395 my $last_tty="";
|
devi@23
|
396 my $last_day="";
|
devi@23
|
397 my $in_range=0;
|
devi@23
|
398
|
devi@31
|
399 my $i=0;
|
devi@32
|
400
|
devi@32
|
401 COMMAND_LINE:
|
devi@31
|
402 for my $k (@Command_Lines_Index) {
|
devi@31
|
403
|
devi@31
|
404 my $cl=$Command_Lines[$Command_Lines_Index[$i++]];
|
devi@31
|
405
|
devi@31
|
406 next unless $cl;
|
devi@23
|
407
|
devi@32
|
408
|
devi@32
|
409 if ($Config{filter}) {
|
devi@32
|
410 # Инициализация фильтра
|
devi@32
|
411 my %filter;
|
devi@32
|
412 for (split /&/,$Config{filter}) {
|
devi@32
|
413 my ($var, $val) = split /=/;
|
devi@32
|
414 $filter{$var} = $val;
|
devi@32
|
415 }
|
devi@32
|
416
|
devi@32
|
417 if ($filter{hostname}) {
|
devi@32
|
418 next COMMAND_LINE unless $Sessions{$cl->{local_session_id}}->{hostname} eq $filter{hostname};
|
devi@32
|
419 }
|
devi@32
|
420
|
devi@35
|
421 if ($filter{user}) {
|
devi@35
|
422 next COMMAND_LINE unless $Sessions{$cl->{local_session_id}}->{user} eq $filter{user};
|
devi@35
|
423 }
|
devi@35
|
424
|
devi@32
|
425 #for my $filter_field (keys %filter) {
|
devi@32
|
426 # next COMMAND_LINE unless $Sessions{$cl->{local_session_id}}->{$filter_field} eq $filter{$filter_field};
|
devi@32
|
427 #}
|
devi@32
|
428 }
|
devi@32
|
429
|
devi@23
|
430 if ($Config{"from"} && $cl->{"cline"} =~ /$Config{"signature"}\s*$Config{"from"}/) {
|
devi@23
|
431 $in_range=1;
|
devi@23
|
432 next;
|
devi@23
|
433 }
|
devi@23
|
434 if ($Config{"to"} && $cl->{"cline"} =~ /$Config{"signature"}\s*$Config{"to"}/) {
|
devi@23
|
435 $in_range=0;
|
devi@23
|
436 next;
|
devi@23
|
437 }
|
devi@23
|
438 next if ($Config{"from"} && $Config{"to"} && !$in_range)
|
devi@23
|
439 ||
|
devi@23
|
440 ($Config{"skip_empty"} =~ /^y/i && $cl->{"cline"} =~ /^\s*$/ )
|
devi@23
|
441 ||
|
devi@23
|
442 ($Config{"skip_wrong"} =~ /^y/i && $cl->{"err"} != 0)
|
devi@23
|
443 ||
|
devi@23
|
444 ($Config{"skip_interrupted"} =~ /^y/i && $cl->{"err"} == 130);
|
devi@23
|
445
|
devi@23
|
446 #my @new_commands=@{$cl->{"new_commands"}};
|
devi@23
|
447 #my @new_files=@{$cl->{"new_files"}};
|
devi@23
|
448
|
devi@31
|
449 if ($cl->{class} eq "note") {
|
devi@31
|
450 my $note = $cl->{note};
|
devi@31
|
451 $note = join ("\n", map ("<p>$_</p>", split (/-\n/, $note)));
|
devi@35
|
452 $note =~ s@(http:[a-zA-Z.0-9/?%-]*)@<a href='$1'>$1</a>@g;
|
devi@35
|
453 $note =~ s@(www\.[a-zA-Z.0-9/?%-]*)@<a href='$1'>$1</a>@g;
|
devi@31
|
454 $Result{"body"} .= "<tr><td colspan='6'>";
|
devi@31
|
455 $Result{"body"} .= "<h4 id='note$note_number'>".$cl->{note_title}."</h4>" if $cl->{note_title};
|
devi@31
|
456 $Result{"body"} .= "".$note."<p/><p/></td></td>";
|
devi@31
|
457
|
devi@31
|
458 if ($cl->{note_title}) {
|
devi@31
|
459 push @{$toc[@toc]},"<a href='#note$note_number'>".$cl->{note_title}."</a>";
|
devi@31
|
460 $note_number++;
|
devi@31
|
461 }
|
devi@31
|
462 next;
|
devi@31
|
463 }
|
devi@31
|
464
|
devi@23
|
465 my $cl_class="cline";
|
devi@23
|
466 my $out_class="output";
|
devi@23
|
467 if ($cl->{"class"}) {
|
devi@23
|
468 $cl_class = $cl->{"class"}."_".$cl_class;
|
devi@23
|
469 $out_class = $cl->{"class"}."_".$out_class;
|
devi@23
|
470 }
|
devi@23
|
471
|
devi@23
|
472 my @new_commands;
|
devi@23
|
473 my @new_files;
|
devi@23
|
474 @new_commands = split (/\s+/, $cl->{"new_commands"}) if defined $cl->{"new_commands"};
|
devi@23
|
475 @new_files = split (/\s+/, $cl->{"new_files"}) if defined $cl->{"new_files"};
|
devi@23
|
476
|
devi@23
|
477 my $output="";
|
devi@23
|
478 if ($Config{"head_lines"} || $Config{"tail_lines"}) {
|
devi@23
|
479 # Partialy output
|
devi@23
|
480 my @lines = split '\n', $cl->{"output"};
|
devi@23
|
481 # head
|
devi@23
|
482 my $mark=1;
|
devi@23
|
483 for (my $i=0; $i<= $#lines && $i < $Config{"head_lines"}; $i++) {
|
devi@23
|
484 $output .= $lines[$i]."\n";
|
devi@23
|
485 }
|
devi@23
|
486 # tail
|
devi@23
|
487 my $start=$#lines-$Config{"tail_lines"}+1;
|
devi@23
|
488 if ($start < 0) {
|
devi@23
|
489 $start=0;
|
devi@23
|
490 $mark=0;
|
devi@23
|
491 }
|
devi@23
|
492 if ($start < $Config{"head_lines"}) {
|
devi@23
|
493 $start=$Config{"head_lines"};
|
devi@23
|
494 $mark=0;
|
devi@23
|
495 }
|
devi@23
|
496 $output .= $Config{"skip_text"}."\n" if $mark;
|
devi@23
|
497 for (my $i=$start; $i<= $#lines; $i++) {
|
devi@23
|
498 $output .= $lines[$i]."\n";
|
devi@23
|
499 }
|
devi@23
|
500 }
|
devi@23
|
501 else {
|
devi@23
|
502 # Full output
|
devi@23
|
503 $output .= $cl->{"output"};
|
devi@23
|
504 }
|
devi@23
|
505 #$output .= "^C\n" if ($cl->{"err"} eq "130");
|
devi@23
|
506
|
devi@23
|
507 #
|
devi@23
|
508 ##
|
devi@23
|
509 ## Начинается собственно вывод
|
devi@23
|
510 ##
|
devi@23
|
511 #
|
devi@23
|
512
|
devi@23
|
513 # <command>
|
devi@23
|
514
|
devi@23
|
515 my ($sec,$min,$hour,$day,$mon,$year,$wday,$yday,$isdst) = localtime($cl->{time});
|
devi@31
|
516 $Stat{FirstCommand} = $cl->{time} unless $Stat{FirstCommand};
|
devi@31
|
517 $Stat{LastCommand} = 0 unless defined $Stat{LastCommand};
|
devi@31
|
518 $Stat{TotalTime} += $cl->{time} - $Stat{LastCommand}
|
devi@31
|
519 if $cl->{time} - $Stat{LastCommand} < $Config{stat_inactivity_interval};
|
devi@31
|
520 $Stat{LastCommand} = $cl->{time};
|
devi@31
|
521 $Stat{TotalCommands} = 0 unless $Stat{TotalCommands};
|
devi@31
|
522 $Stat{TotalCommands}++;
|
devi@31
|
523
|
devi@23
|
524 # Добавляем спереди 0 для удобочитаемости
|
devi@23
|
525 $min = "0".$min if $min =~ /^.$/;
|
devi@23
|
526 $hour = "0".$hour if $hour =~ /^.$/;
|
devi@23
|
527 $sec = "0".$sec if $sec =~ /^.$/;
|
devi@23
|
528
|
devi@23
|
529 $class=$cl->{"out_class"};
|
devi@23
|
530 $class =~ s/output$//;
|
devi@23
|
531
|
devi@31
|
532 $Stat{ErrorCommands}++
|
devi@31
|
533 if $class =~ /wrong/;
|
devi@23
|
534
|
devi@23
|
535 $Result{"body"} .= "<tr class='command'>\n";
|
devi@23
|
536
|
devi@23
|
537
|
devi@23
|
538 # DAY CHANGE
|
devi@23
|
539 if ( $last_day ne $day) {
|
devi@23
|
540 #$Result{"body"} .= "<td colspan='6'><p></p><h3>День ",$day,"</h4></td></tr><tr>";
|
devi@23
|
541 $Result{"body"} .= "<td colspan='6'><p></p><h3 id='day$day'>".$Day_Name[$wday]."</h4></td></tr><tr>";
|
devi@31
|
542 push @toc, "<a href='#day$day'>".$Day_Name[$wday]."</a>\n";
|
devi@23
|
543 $last_day=$day;
|
devi@23
|
544 }
|
devi@23
|
545
|
devi@23
|
546 # CONSOLE CHANGE
|
devi@23
|
547 if ( $last_tty ne $cl->{"tty"}) {
|
devi@32
|
548 my $host;
|
devi@32
|
549 #$host = $Sessions{$cl->{local_session_id}}->{user}."@".$Sessions{$cl->{local_session_id}}->{hostname};
|
devi@32
|
550 $Result{"body"} .= "<td colspan='6'><table><tr><td class='ttychange' width='140' align='center'>".$cl->{"tty"}."</td><td>$host</td></tr></table></td></tr><tr>";
|
devi@23
|
551 $last_tty=$cl->{"tty"};
|
devi@23
|
552 }
|
devi@23
|
553
|
devi@23
|
554 # TIME
|
devi@23
|
555 if ($Config{"show_time"} =~ /^y/i) {
|
devi@23
|
556 $Result{"body"} .= "<td valign='top' class='time' width='$Config{time_width}'><pre>".
|
devi@23
|
557 $hour. ":". $min. ":". $sec.
|
devi@23
|
558 "</td>";
|
devi@23
|
559 } else {
|
devi@23
|
560 $Result{"body"} .= "<td width='0'/>"
|
devi@23
|
561 }
|
devi@23
|
562
|
devi@23
|
563 # COMMAND
|
devi@23
|
564 $Result{"body"} .= "<td class='script'>\n";
|
devi@23
|
565 $Result{"body"} .= "<pre class='${class}cline'>\n";
|
devi@31
|
566 my $cline = $cl->{"prompt"}.$cl->{"cline"};
|
devi@23
|
567 $cline =~ s/\n//;
|
devi@32
|
568
|
devi@32
|
569 #$cline .= "(".$Sessions{$cl->{local_session_id}}.")";
|
devi@32
|
570
|
devi@31
|
571 my $hint = make_comment($cl->{"cline"});
|
devi@31
|
572 $cline = "<div title='$hint'>$cline</div>" if $hint;
|
devi@31
|
573 $Result{"body"} .= $cline;
|
devi@23
|
574 $Result{"body"} .= "</pre>\n";
|
devi@23
|
575
|
devi@23
|
576 my $last_command = $cl->{"last_command"};
|
devi@23
|
577 if (!(
|
devi@23
|
578 $Config{"suppress_editors"} =~ /^y/i && grep ($_ eq $last_command, @{$Config{"editors"}}) ||
|
devi@23
|
579 $Config{"suppress_pagers"} =~ /^y/i && grep ($_ eq $last_command, @{$Config{"pagers"}}) ||
|
devi@23
|
580 $Config{"suppress_terminal"}=~ /^y/i && grep ($_ eq $last_command, @{$Config{"terminal"}})
|
devi@23
|
581 )) {
|
devi@23
|
582
|
devi@23
|
583 $Result{"body"} .= "<pre class='".$cl->{out_class}."'>";
|
devi@23
|
584 $Result{"body"} .= $output;
|
devi@23
|
585 $Result{"body"} .= "</pre>\n";
|
devi@23
|
586 }
|
devi@23
|
587
|
devi@23
|
588 # DIFF
|
devi@23
|
589 if ( $Config{"show_diffs"} =~ /^y/i && $cl->{"diff"}) {
|
devi@23
|
590 $Result{"body"} .= "<table><tr><td width='5'/><td class='diff'><pre>";
|
devi@23
|
591 $Result{"body"} .= $cl->{"diff"};
|
devi@23
|
592 $Result{"body"} .= "</pre></td></tr></table>";
|
devi@23
|
593 }
|
devi@31
|
594
|
devi@31
|
595 #NOTES
|
devi@31
|
596 if ( $Config{"show_notes"} =~ /^y/i && $cl->{"note"}) {
|
devi@31
|
597 my $note=$cl->{"note"};
|
devi@31
|
598 $note =~ s/\n/<br\/>\n/msg;
|
devi@35
|
599 $note =~ s@(http:[a-zA-Z.0-9/?%-]*)@<a href='$1'>$1</a>@g;
|
devi@35
|
600 $note =~ s@(www\.[a-zA-Z.0-9/?%-]*)@<a href='$1'>$1</a>@g;
|
devi@31
|
601 # Ширину пока не используем
|
devi@31
|
602 # $Result{"body"} .= "<table width='$Config{note_width}' class='note'>";
|
devi@31
|
603 $Result{"body"} .= "<table class='note'>";
|
devi@31
|
604 $Result{"body"} .= "<tr><td class='note_title'>".$cl->{note_title}."</td></tr>" if $cl->{note_title};
|
devi@31
|
605 $Result{"body"} .= "<tr><td width='100%' class='note_text'>".$note."</td></tr>";
|
devi@31
|
606 $Result{"body"} .= "</table>\n";
|
devi@31
|
607 }
|
devi@23
|
608
|
devi@23
|
609 # COMMENT
|
devi@23
|
610 if ( $Config{"show_comments"} =~ /^y/i) {
|
devi@31
|
611 my $comment = make_comment($cl->{"cline"});
|
devi@23
|
612 if ($comment) {
|
devi@23
|
613 $Result{"body"} .= "<table width='$Config{comment_width}'>".
|
devi@23
|
614 "<tr><td width='5'/><td>";
|
devi@23
|
615 $Result{"body"} .= "<table class='note' width='100%'>";
|
devi@23
|
616 $Result{"body"} .= $comment;
|
devi@23
|
617 $Result{"body"} .= "</table>\n";
|
devi@23
|
618 $Result{"body"} .= "</td></tr></table>";
|
devi@23
|
619 }
|
devi@23
|
620 }
|
devi@23
|
621
|
devi@23
|
622 # Вывод очередной команды окончен
|
devi@23
|
623 $Result{"body"} .= "</td>\n";
|
devi@23
|
624 $Result{"body"} .= "</tr>\n";
|
devi@23
|
625 }
|
devi@23
|
626
|
devi@23
|
627 $Result{"body"} .= "</table>\n";
|
devi@23
|
628
|
devi@31
|
629 #$Result{"stat"} = "<hr/>";
|
devi@31
|
630
|
devi@31
|
631 %StatNames = (
|
devi@31
|
632 FirstCommand => "Время первой команды журнала",
|
devi@31
|
633 LastCommand => "Время последней команды журнала",
|
devi@31
|
634 TotalCommands => "Количество командных строк в журнале",
|
devi@32
|
635 ErrorsPercentage => "Процент команд с ненулевым кодом завершения, %",
|
devi@31
|
636 TotalTime => "Суммарное время работы с терминалом <sup><font size='-2'>*</font></sup>, час",
|
devi@31
|
637 CommandsPerTime => "Количество командных строк в единицу времени, команда/мин",
|
devi@31
|
638 CommandsFDistribution => "Частота использования команд",
|
devi@31
|
639 CommandsFDistribution => "Частота использования команд",
|
devi@31
|
640 RareCommands => "Частота использования этих команд < 0.5%",
|
devi@31
|
641 );
|
devi@31
|
642 @StatOrder = (
|
devi@31
|
643 FirstCommand,
|
devi@31
|
644 LastCommand,
|
devi@31
|
645 TotalCommands,
|
devi@31
|
646 ErrorsPercentage,
|
devi@31
|
647 TotalTime,
|
devi@31
|
648 CommandsPerTime,
|
devi@31
|
649 CommandsFDistribution,
|
devi@31
|
650 RareCommands,
|
devi@31
|
651 );
|
devi@31
|
652
|
devi@31
|
653 # Подготовка статистики к выводу
|
devi@31
|
654 # Некоторые значения пересчитываются!
|
devi@31
|
655 # Дальше их лучше уже не использовать!!!
|
devi@31
|
656
|
devi@31
|
657 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($Stat{FirstCommand});
|
devi@31
|
658 $Stat{FirstCommand} = sprintf "%02i:%02i:%02i %04i-%2i-%2i", $hour, $min, $sec, $year+1900, $mon+1, $mday;
|
devi@31
|
659 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($Stat{LastCommand});
|
devi@31
|
660 $Stat{LastCommand} = sprintf "%02i:%02i:%02i %04i-%2i-%2i", $hour, $min, $sec, $year+1900, $mon+1, $mday;
|
devi@31
|
661 $Stat{ErrorsPercentage} = sprintf "%5.2f", $Stat{ErrorCommands}*100/$Stat{TotalCommands}
|
devi@31
|
662 if $Stat{TotalCommands};
|
devi@31
|
663 $Stat{CommandsPerTime} = sprintf "%5.2f", $Stat{TotalCommands}*60/$Stat{TotalTime}
|
devi@31
|
664 if $Stat{TotalTime};
|
devi@32
|
665 $Stat{TotalTime} = sprintf "%5.2f", $Stat{TotalTime}/60/60;
|
devi@31
|
666
|
devi@31
|
667 my $total_commands=0;
|
devi@31
|
668 for $command (keys %CommandsFDistribution){
|
devi@31
|
669 $total_commands += $CommandsFDistribution{$command};
|
devi@31
|
670 }
|
devi@31
|
671 if ($total_commands) {
|
devi@31
|
672 for $command (reverse sort {$CommandsFDistribution{$a} <=> $CommandsFDistribution{$b}} keys %CommandsFDistribution){
|
devi@32
|
673 my $command_html;
|
devi@31
|
674 my $percentage = sprintf "%5.2f",$CommandsFDistribution{$command}*100/$total_commands;
|
devi@31
|
675 if ($percentage < 0.5) {
|
devi@31
|
676 my $hint = make_comment($command);
|
devi@32
|
677 $command_html = "$command";
|
devi@31
|
678 $command_html = "<span title='$hint' class='hint'>$command_html</span>" if $hint;
|
devi@31
|
679 my $command_html = "<tt>$command_html</tt>";
|
devi@31
|
680 $Stat{RareCommands} .= $command_html."<sub><font size='-2'>".$CommandsFDistribution{$command}."</font></sub> , ";
|
devi@31
|
681 }
|
devi@31
|
682 else {
|
devi@31
|
683 my $hint = make_comment($command);
|
devi@32
|
684 $command_html = "$command";
|
devi@31
|
685 $command_html = "<span title='$hint' class='hint'>$command_html</span>" if $hint;
|
devi@31
|
686 my $command_html = "<tt>$command_html</tt>";
|
devi@31
|
687 $percentage = sprintf "%5.2f",$percentage;
|
devi@31
|
688 $Stat{CommandsFDistribution} .= "<tr><td>".$command_html."</td><td>".$CommandsFDistribution{$command}."</td>".
|
devi@31
|
689 "<td>|".("="x int($CommandsFDistribution{$command}*100/$total_commands))."| $percentage%</td></tr>";
|
devi@31
|
690 }
|
devi@31
|
691 }
|
devi@31
|
692 $Stat{CommandsFDistribution} = "<table>".$Stat{CommandsFDistribution}."</table>";
|
devi@32
|
693 $Stat{RareCommands} =~ s/, $// if $Stat{RareCommands};
|
devi@31
|
694 }
|
devi@31
|
695
|
devi@23
|
696 $Result{"stat"} .= "<h2 id='stat'>Статистика</h2>";
|
devi@31
|
697 $Result{"stat"} .= "<table>";
|
devi@31
|
698 for my $stat (@StatOrder) {
|
devi@32
|
699 $Result{"stat"} .= "<tr valign='top'><td width='300'>".$StatNames{"$stat"}."</td><td>".$Stat{"$stat"}."</td></tr>"
|
devi@32
|
700 if $Stat{"$stat"};
|
devi@31
|
701 }
|
devi@31
|
702
|
devi@31
|
703 $Result{"stat"} .= "</table>";
|
devi@31
|
704 $Result{"stat"} .= "<font size='-2'>____<br/>*) Интервалы неактивности длительностью ".($Config{stat_inactivity_interval}/60)." минут и более не учитываются</font></br>";
|
devi@31
|
705
|
devi@31
|
706 #$Result{"help"} .= "<hr/>";
|
devi@23
|
707 $Result{"help"} .= "<h2 id='help'>Справка</h2>";
|
devi@23
|
708 $Result{"help"} .= "$Html_Help<br/>";
|
devi@31
|
709 #$Result{"about"} .= "<hr/>";
|
devi@23
|
710 $Result{"about"} .= "<h2 id='about'>О программе</h2>";
|
devi@23
|
711 $Result{"about"} .= "$Html_About";
|
devi@23
|
712 $Result{"footer"} .= "</body>\n";
|
devi@23
|
713 $Result{"footer"} .= "</html>\n";
|
devi@23
|
714
|
devi@31
|
715 $Result{"title"} = "Журнал лабораторных работ";
|
devi@31
|
716 $Result{"title"}.= " -- ".$course_student if $course_student;
|
devi@31
|
717 if ($course_date) {
|
devi@31
|
718 $Result{"title"}.= " -- ".$course_date;
|
devi@31
|
719 $Result{"title"}.= "/".$course_code if $course_code;
|
devi@31
|
720 }
|
devi@31
|
721 else {
|
devi@31
|
722 $Result{"title"}.= " -- ".$course_code if $course_code;
|
devi@31
|
723 }
|
devi@31
|
724
|
devi@23
|
725 # Заголовок генерируется позже всего
|
devi@23
|
726 # Тогда, когда известно уже, что должно быть написано в
|
devi@23
|
727 # оглавлении
|
devi@23
|
728 $Result{"header"} = <<HEADER;
|
devi@23
|
729 <html>
|
devi@23
|
730 <head>
|
devi@23
|
731 <meta content='text/html; charset=utf-8' http-equiv='Content-Type' />
|
devi@27
|
732 <link rel='stylesheet' href='$Config{frontend_css}' type='text/css'/>
|
devi@31
|
733 <title>$Result{title}</title>
|
devi@23
|
734 </head>
|
devi@23
|
735 <body>
|
devi@23
|
736 <script>
|
devi@23
|
737 $Html_JavaScript
|
devi@23
|
738 </script>
|
devi@31
|
739 <h1>Журнал лабораторных работ</h1>
|
devi@23
|
740
|
devi@31
|
741 HEADER
|
devi@31
|
742 $Result{"header"} .= "<p>" if $course_student || $course_trainer || $course_name || $course_code || $course_date || $course_center;
|
devi@31
|
743 $Result{"header"} .= "Выполнил $course_student<br/>" if $course_student;
|
devi@31
|
744 $Result{"header"} .= "Проверил $course_trainer <br/>" if $course_trainer;
|
devi@31
|
745 $Result{"header"} .= "Курс " if $course_name || $course_code || $course_date;
|
devi@31
|
746 $Result{"header"} .= "$course_name " if $course_name;
|
devi@31
|
747 $Result{"header"} .= "($course_code)" if $course_code;
|
devi@31
|
748 $Result{"header"} .= ", $course_date<br/>" if $course_date;
|
devi@31
|
749 $Result{"header"} .= "Учебный центр $course_center <br/>" if $course_center;
|
devi@31
|
750 $Result{"header"} .= "</p>" if $course_student || $course_trainer || $course_name || $course_code || $course_date || $course_center;
|
devi@23
|
751
|
devi@31
|
752 my $toc = collapse_list (\@toc);
|
devi@31
|
753 $Result{"header"} .= <<HEADER;
|
devi@23
|
754 <ul>
|
devi@23
|
755 <li><a href='#log'>Журнал</a></li>
|
devi@23
|
756 <ul>$toc</ul>
|
devi@23
|
757 <li><a href='#stat'>Статистика</a></li>
|
devi@23
|
758 <li><a href='#help'>Справка</a></li>
|
devi@23
|
759 <li><a href='#about'>О программе</a></li>
|
devi@23
|
760 </ul>
|
devi@23
|
761
|
devi@23
|
762 <h2 id="log">Журнал</h2>
|
devi@23
|
763 HEADER
|
devi@31
|
764 $Result{"header"} .= "<table id='visibility_form' class='visibility_form'><tr><td><form>\n";
|
devi@23
|
765 for my $element (keys %Elements_Visibility)
|
devi@23
|
766 {
|
devi@23
|
767 my @e = split /\s+/, $element;
|
devi@23
|
768 my $showhide = join "", map { "ShowHide('$_');" } @e ;
|
devi@23
|
769 $Result{"header"} .= "<input type='checkbox' name='$e[0]' onclick=\"$showhide\" checked>".
|
devi@23
|
770 $Elements_Visibility{$element}.
|
devi@23
|
771 "</input><br>\n";
|
devi@23
|
772 }
|
devi@23
|
773
|
devi@23
|
774 $Result{"header"} .= "</form></td></tr></table>\n";
|
devi@23
|
775
|
devi@27
|
776 if ($output_filename eq "-") {
|
devi@27
|
777 print $Result{"header"}, $Result{"body"}, $Result{"stat"}, $Result{"help"}, $Result{"about"}, $Result{"footer"};
|
devi@27
|
778 }
|
devi@27
|
779 else {
|
devi@27
|
780 open(OUT, ">", $output_filename)
|
devi@27
|
781 or die "Can't open $output_filename for writing\n";
|
devi@27
|
782 print OUT $Result{"header"}, $Result{"body"}, $Result{"stat"}, $Result{"help"}, $Result{"about"}, $Result{"footer"};
|
devi@27
|
783 close(OUT);
|
devi@27
|
784 }
|
devi@23
|
785 }
|
devi@23
|
786
|
devi@23
|
787
|
devi@23
|
788
|
devi@31
|
789 sub collapse_list($)
|
devi@31
|
790 {
|
devi@31
|
791 my $res = "";
|
devi@31
|
792 for my $elem (@{$_[0]}) {
|
devi@31
|
793 if (ref $elem eq "ARRAY") {
|
devi@31
|
794 $res .= "<ul>".collapse_list($elem)."</ul>";
|
devi@31
|
795 }
|
devi@31
|
796 else
|
devi@31
|
797 {
|
devi@31
|
798 $res .= "<li>".$elem."</li>";
|
devi@31
|
799 }
|
devi@31
|
800 }
|
devi@31
|
801 return $res;
|
devi@31
|
802 }
|
devi@31
|
803
|
devi@23
|
804
|
devi@23
|
805
|
devi@23
|
806
|
devi@23
|
807 sub init_variables
|
devi@23
|
808 {
|
devi@23
|
809 $Html_Help = <<HELP;
|
devi@31
|
810 Для того чтобы использовать LiLaLo, не нужно знать ничего особенного:
|
devi@31
|
811 всё происходит само собой.
|
devi@31
|
812 Однако, чтобы ведение и последующее использование журналов
|
devi@31
|
813 было как можно более эффективным, желательно иметь в виду следующее:
|
devi@31
|
814 <ul>
|
devi@31
|
815 <li><p>
|
devi@31
|
816 В журнал автоматически попадают все команды, данные в любом терминале системы.
|
devi@31
|
817 </p></li>
|
devi@31
|
818 <li><p>
|
devi@31
|
819 Для того чтобы убедиться, что журнал на текущем терминале ведётся,
|
devi@31
|
820 и команды записываются, дайте команду w.
|
devi@31
|
821 В поле WHAT, соответствующем текущему терминалу,
|
devi@31
|
822 должна быть указана программа script.
|
devi@31
|
823 </p></li>
|
devi@31
|
824 <li><p>
|
devi@31
|
825 Если код завершения команды равен нулю,
|
devi@31
|
826 команда была выполнена без ошибок.
|
devi@36
|
827 Команды, код завершения которых отличен от нуля, выделяются цветом.
|
devi@31
|
828 <table>
|
devi@31
|
829 <tr class='command'>
|
devi@31
|
830 <td class='script'>
|
devi@31
|
831 <pre class='wrong_cline'>
|
devi@31
|
832 \$ l s-l</pre>
|
devi@31
|
833 <pre class='wrong_output'>bash: l: command not found
|
devi@31
|
834 </pre>
|
devi@31
|
835 </td>
|
devi@31
|
836 </tr>
|
devi@31
|
837 </table>
|
devi@31
|
838 <br/>
|
devi@31
|
839 </p></li>
|
devi@31
|
840 <li><p>
|
devi@31
|
841 Команды, ход выполнения которых был прерван пользователем, выделяются цветом.
|
devi@31
|
842 <table>
|
devi@31
|
843 <tr class='command'>
|
devi@31
|
844 <td class='script'>
|
devi@31
|
845 <pre class='interrupted_cline'>
|
devi@31
|
846 \$ find / -name abc</pre>
|
devi@31
|
847 <pre class='interrupted_output'>find: /home/devi-orig/.gnome2: Keine Berechtigung
|
devi@31
|
848 find: /home/devi-orig/.gnome2_private: Keine Berechtigung
|
devi@31
|
849 find: /home/devi-orig/.nautilus/metafiles: Keine Berechtigung
|
devi@31
|
850 find: /home/devi-orig/.metacity: Keine Berechtigung
|
devi@31
|
851 find: /home/devi-orig/.inkscape: Keine Berechtigung
|
devi@31
|
852 ^C
|
devi@31
|
853 </pre>
|
devi@31
|
854 </td>
|
devi@31
|
855 </tr>
|
devi@31
|
856 </table>
|
devi@31
|
857 <br/>
|
devi@31
|
858 </p></li>
|
devi@31
|
859 <li><p>
|
devi@31
|
860 Команды, выполненные с привилегиями суперпользователя,
|
devi@31
|
861 выделяются слева красной чертой.
|
devi@31
|
862 <table>
|
devi@31
|
863 <tr class='command'>
|
devi@31
|
864 <td class='script'>
|
devi@31
|
865 <pre class='_root_cline'>
|
devi@31
|
866 # id</pre>
|
devi@31
|
867 <pre class='_root_output'>
|
devi@31
|
868 uid=0(root) gid=0(root) Gruppen=0(root)
|
devi@31
|
869 </pre>
|
devi@31
|
870 </td>
|
devi@31
|
871 </tr>
|
devi@31
|
872 </table>
|
devi@31
|
873 <br/>
|
devi@31
|
874 </p></li>
|
devi@31
|
875 <li><p>
|
devi@31
|
876 Изменения, внесённые в текстовый файл с помощью редактора,
|
devi@31
|
877 запоминаются и показываются в журнале в формате ed.
|
devi@31
|
878 Строки, начинающиеся символом "<", удалены, а строки,
|
devi@31
|
879 начинающиеся символом ">" -- добавлены.
|
devi@31
|
880 <table>
|
devi@31
|
881 <tr class='command'>
|
devi@31
|
882 <td class='script'>
|
devi@31
|
883 <pre class='cline'>
|
devi@31
|
884 \$ vi ~/.bashrc</pre>
|
devi@31
|
885 <table><tr><td width='5'/><td class='diff'><pre>2a3,5
|
devi@31
|
886 > if [ -f /usr/local/etc/bash_completion ]; then
|
devi@31
|
887 > . /usr/local/etc/bash_completion
|
devi@31
|
888 > fi
|
devi@31
|
889 </pre></td></tr></table></td>
|
devi@31
|
890 </tr>
|
devi@31
|
891 </table>
|
devi@31
|
892 <br/>
|
devi@31
|
893 </p></li>
|
devi@31
|
894 <li><p>
|
devi@31
|
895 Для того чтобы получить краткую справочную информацию о команде,
|
devi@31
|
896 нужно подвести к ней мышь. Во всплывающей подсказке появится краткое
|
devi@31
|
897 описание команды.
|
devi@31
|
898 </p></li>
|
devi@31
|
899 <li><p>
|
devi@31
|
900 Время ввода команды, показанное в журнале, соответствует времени
|
devi@31
|
901 <i>начала ввода командной строки</i>, которое равно тому моменту,
|
devi@31
|
902 когда на терминале появилось приглашение интерпретатора
|
devi@31
|
903 </p></li>
|
devi@31
|
904 <li><p>
|
devi@31
|
905 Имя терминала, на котором была введена команда, показано в специальном блоке.
|
devi@31
|
906 Этот блок показывается только в том случае, если терминал
|
devi@31
|
907 текущей команды отличается от терминала предыдущей.
|
devi@31
|
908 </p></li>
|
devi@31
|
909 <li><p>
|
devi@31
|
910 Вывод не интересующих вас в настоящий момент элементов журнала,
|
devi@31
|
911 таких как время, имя терминала и других, можно отключить.
|
devi@31
|
912 Для этого нужно воспользоваться <a href='#visibility_form'>формой управления журналом</a>
|
devi@31
|
913 вверху страницы.
|
devi@31
|
914 </p></li>
|
devi@31
|
915 <li><p>
|
devi@31
|
916 Небольшие комментарии к командам можно вставлять прямо из командной строки.
|
devi@31
|
917 Комментарий вводится прямо в командную строку, после символов #^ или #v.
|
devi@31
|
918 Символы ^ и v показывают направление выбора команды, к которой относится комментарий:
|
devi@31
|
919 ^ - к предыдущей, v - к следующей.
|
devi@31
|
920 Например, если в командной строке было введено:
|
devi@31
|
921 <pre class='cline'>
|
devi@31
|
922 \$ whoami
|
devi@31
|
923 </pre>
|
devi@31
|
924 <pre class='output'>
|
devi@31
|
925 user
|
devi@31
|
926 </pre>
|
devi@31
|
927 <pre class='cline'>
|
devi@31
|
928 \$ #^ Интересно, кто я?
|
devi@31
|
929 </pre>
|
devi@31
|
930 в журнале это будет выглядеть так:
|
devi@31
|
931
|
devi@31
|
932 <pre class='cline'>
|
devi@31
|
933 \$ whoami
|
devi@31
|
934 </pre>
|
devi@31
|
935 <pre class='output'>
|
devi@31
|
936 user
|
devi@31
|
937 </pre>
|
devi@31
|
938 <table class='note'><tr><td width='100%' class='note_text'>
|
devi@31
|
939 <tr> <td> Интересно, кто я?<br/> </td></tr></table>
|
devi@31
|
940 </p></li>
|
devi@31
|
941 <li><p>
|
devi@31
|
942 Если комментарий содержит несколько строк,
|
devi@31
|
943 его можно вставить в журнал следующим образом:
|
devi@31
|
944 <pre class='cline'>
|
devi@31
|
945 \$ whoami
|
devi@31
|
946 </pre>
|
devi@31
|
947 <pre class='output'>
|
devi@31
|
948 user
|
devi@31
|
949 </pre>
|
devi@31
|
950 <pre class='cline'>
|
devi@31
|
951 \$ cat > /dev/null #^ Интересно, кто я?
|
devi@31
|
952 </pre>
|
devi@31
|
953 <pre class='output'>
|
devi@31
|
954 Программа whoami выводит имя пользователя, под которым
|
devi@31
|
955 мы зарегистрировались в системе.
|
devi@31
|
956 -
|
devi@31
|
957 Она не может ответить на вопрос о нашем назначении
|
devi@31
|
958 в этом мире.
|
devi@31
|
959 </pre>
|
devi@31
|
960 В журнале это будет выглядеть так:
|
devi@31
|
961 <table>
|
devi@31
|
962 <tr class='command'>
|
devi@31
|
963 <td class='script'>
|
devi@31
|
964 <pre class='cline'>
|
devi@31
|
965 \$ whoami</pre>
|
devi@31
|
966 <pre class='output'>user
|
devi@31
|
967 </pre>
|
devi@31
|
968 <table class='note'><tr><td class='note_title'>Интересно, кто я?</td></tr><tr><td width='100%' class='note_text'>
|
devi@31
|
969 Программа whoami выводит имя пользователя, под которым<br/>
|
devi@31
|
970 мы зарегистрировались в системе.<br/>
|
devi@31
|
971 <br/>
|
devi@31
|
972 Она не может ответить на вопрос о нашем назначении<br/>
|
devi@31
|
973 в этом мире.<br/>
|
devi@31
|
974 </td></tr></table>
|
devi@31
|
975 </td>
|
devi@31
|
976 </tr>
|
devi@31
|
977 </table>
|
devi@31
|
978 Для разделения нескольких абзацев между собой
|
devi@31
|
979 используйте символ "-", один в строке.
|
devi@31
|
980 <br/>
|
devi@31
|
981 </p></li>
|
devi@31
|
982 <li><p>
|
devi@31
|
983 Комментарии, не относящиеся непосредственно ни к какой из команд,
|
devi@31
|
984 добавляются точно таким же способом, только вместо симолов #^ или #v
|
devi@31
|
985 нужно использовать символы #=
|
devi@31
|
986 </p></li>
|
devi@31
|
987 </ul>
|
devi@23
|
988 HELP
|
devi@23
|
989
|
devi@23
|
990 $Html_About = <<ABOUT;
|
devi@23
|
991 <p>
|
devi@23
|
992 LiLaLo (L3) расшифровывается как Live Lab Log.<br/>
|
devi@29
|
993 Программа разработана для повышения эффективности обучения Unix/Linux-системам.<br/>
|
devi@23
|
994 (c) Игорь Чубин, 2004-2005<br/>
|
devi@23
|
995 </p>
|
devi@23
|
996 ABOUT
|
devi@23
|
997 $Html_About.='$Id$ </p>';
|
devi@23
|
998
|
devi@23
|
999 $Html_JavaScript = <<JS;
|
devi@23
|
1000 function getElementsByClassName(Class_Name)
|
devi@23
|
1001 {
|
devi@23
|
1002 var Result=new Array();
|
devi@23
|
1003 var All_Elements=document.all || document.getElementsByTagName('*');
|
devi@23
|
1004 for (i=0; i<All_Elements.length; i++)
|
devi@23
|
1005 if (All_Elements[i].className==Class_Name)
|
devi@23
|
1006 Result.push(All_Elements[i]);
|
devi@23
|
1007 return Result;
|
devi@23
|
1008 }
|
devi@23
|
1009 function ShowHide (name)
|
devi@23
|
1010 {
|
devi@23
|
1011 elements=getElementsByClassName(name);
|
devi@23
|
1012 for(i=0; i<elements.length; i++)
|
devi@23
|
1013 if (elements[i].style.display == "none")
|
devi@23
|
1014 elements[i].style.display = "";
|
devi@23
|
1015 else
|
devi@23
|
1016 elements[i].style.display = "none";
|
devi@23
|
1017 //if (elements[i].style.visibility == "hidden")
|
devi@23
|
1018 // elements[i].style.visibility = "visible";
|
devi@23
|
1019 //else
|
devi@23
|
1020 // elements[i].style.visibility = "hidden";
|
devi@23
|
1021 }
|
devi@23
|
1022 function filter_by_output(text)
|
devi@23
|
1023 {
|
devi@23
|
1024
|
devi@23
|
1025 var jjj=0;
|
devi@23
|
1026
|
devi@23
|
1027 elements=getElementsByClassName('command');
|
devi@23
|
1028 for(i=0; i<elements.length; i++) {
|
devi@23
|
1029 subelems = elements[i].getElementsByTagName('pre');
|
devi@23
|
1030 for(j=0; j<subelems.length; j++) {
|
devi@23
|
1031 if (subelems[j].className = 'output') {
|
devi@23
|
1032 var str = new String(subelems[j].nodeValue);
|
devi@23
|
1033 if (jjj != 1) {
|
devi@23
|
1034 alert(str);
|
devi@23
|
1035 jjj=1;
|
devi@23
|
1036 }
|
devi@23
|
1037 if (str.indexOf(text) >0)
|
devi@23
|
1038 subelems[j].style.display = "none";
|
devi@23
|
1039 else
|
devi@23
|
1040 subelems[j].style.display = "";
|
devi@23
|
1041
|
devi@23
|
1042 }
|
devi@23
|
1043
|
devi@23
|
1044 }
|
devi@23
|
1045 }
|
devi@23
|
1046
|
devi@23
|
1047 }
|
devi@23
|
1048 JS
|
devi@23
|
1049
|
devi@23
|
1050 %Search_Machines = (
|
devi@23
|
1051 "google" => { "query" => "http://www.google.com/search?q=" ,
|
devi@28
|
1052 "icon" => "$Config{frontend_google_ico}" },
|
devi@23
|
1053 "freebsd" => { "query" => "http://www.freebsd.org/cgi/man.cgi?query=",
|
devi@28
|
1054 "icon" => "$Config{frontend_freebsd_ico}" },
|
devi@23
|
1055 "linux" => { "query" => "http://man.he.net/?topic=",
|
devi@28
|
1056 "icon" => "$Config{frontend_linux_ico}"},
|
devi@23
|
1057 "opennet" => { "query" => "http://www.opennet.ru/search.shtml?words=",
|
devi@28
|
1058 "icon" => "$Config{frontend_opennet_ico}"},
|
devi@23
|
1059 "local" => { "query" => "http://www.freebsd.org/cgi/man.cgi?query=",
|
devi@28
|
1060 "icon" => "$Config{frontend_local_ico}" },
|
devi@23
|
1061
|
devi@23
|
1062 );
|
devi@23
|
1063
|
devi@23
|
1064 %Elements_Visibility = (
|
devi@23
|
1065 "note" => "замечания",
|
devi@23
|
1066 "diff" => "редактор",
|
devi@23
|
1067 "time" => "время",
|
devi@23
|
1068 "ttychange" => "терминал",
|
devi@23
|
1069 "wrong_output wrong_cline wrong_root_output wrong_root_cline"
|
devi@23
|
1070 => "команды с ошибками",
|
devi@23
|
1071 "interrupted_output interrupted_cline interrupted_root_output interrupted_root_cline"
|
devi@23
|
1072 => "прерванные команды",
|
devi@23
|
1073 "tab_completion_output tab_completion_cline"
|
devi@23
|
1074 => "продолжение с помощью tab"
|
devi@23
|
1075 );
|
devi@23
|
1076
|
devi@23
|
1077 @Day_Name = qw/ Воскресенье Понедельник Вторник Среда Четверг Пятница Суббота /;
|
devi@23
|
1078 @Month_Name = qw/ Январь Февраль Март Апрель Май Июнь Июль Август Сентябрь Октябрь Ноябрь Декабрь /;
|
devi@23
|
1079 @Of_Month_Name = qw/ Января Февраля Марта Апреля Мая Июня Июля Августа Сентября Октября Ноября Декабря /;
|
devi@23
|
1080 }
|
devi@23
|
1081
|