lilalo
annotate l3-frontend @ 34:34f3ce44c365
lm-install:
Инсталляция запуска l3-agent в .bash_profile
Инсталляция запуска l3-agent в .bash_profile
author | devi |
---|---|
date | Mon Nov 14 09:17:49 2005 +0200 (2005-11-14) |
parents | 196c82b6e538 |
children | 5f60fe514d49 |
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@31 | 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@31 | 271 @{${$cl}->{"new_commands"}} =(); |
devi@31 | 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@32 | 421 #for my $filter_field (keys %filter) { |
devi@32 | 422 # next COMMAND_LINE unless $Sessions{$cl->{local_session_id}}->{$filter_field} eq $filter{$filter_field}; |
devi@32 | 423 #} |
devi@32 | 424 } |
devi@32 | 425 |
devi@23 | 426 if ($Config{"from"} && $cl->{"cline"} =~ /$Config{"signature"}\s*$Config{"from"}/) { |
devi@23 | 427 $in_range=1; |
devi@23 | 428 next; |
devi@23 | 429 } |
devi@23 | 430 if ($Config{"to"} && $cl->{"cline"} =~ /$Config{"signature"}\s*$Config{"to"}/) { |
devi@23 | 431 $in_range=0; |
devi@23 | 432 next; |
devi@23 | 433 } |
devi@23 | 434 next if ($Config{"from"} && $Config{"to"} && !$in_range) |
devi@23 | 435 || |
devi@23 | 436 ($Config{"skip_empty"} =~ /^y/i && $cl->{"cline"} =~ /^\s*$/ ) |
devi@23 | 437 || |
devi@23 | 438 ($Config{"skip_wrong"} =~ /^y/i && $cl->{"err"} != 0) |
devi@23 | 439 || |
devi@23 | 440 ($Config{"skip_interrupted"} =~ /^y/i && $cl->{"err"} == 130); |
devi@23 | 441 |
devi@23 | 442 #my @new_commands=@{$cl->{"new_commands"}}; |
devi@23 | 443 #my @new_files=@{$cl->{"new_files"}}; |
devi@23 | 444 |
devi@31 | 445 if ($cl->{class} eq "note") { |
devi@31 | 446 my $note = $cl->{note}; |
devi@31 | 447 $note = join ("\n", map ("<p>$_</p>", split (/-\n/, $note))); |
devi@31 | 448 $Result{"body"} .= "<tr><td colspan='6'>"; |
devi@31 | 449 $Result{"body"} .= "<h4 id='note$note_number'>".$cl->{note_title}."</h4>" if $cl->{note_title}; |
devi@31 | 450 $Result{"body"} .= "".$note."<p/><p/></td></td>"; |
devi@31 | 451 |
devi@31 | 452 if ($cl->{note_title}) { |
devi@31 | 453 push @{$toc[@toc]},"<a href='#note$note_number'>".$cl->{note_title}."</a>"; |
devi@31 | 454 $note_number++; |
devi@31 | 455 } |
devi@31 | 456 next; |
devi@31 | 457 } |
devi@31 | 458 |
devi@23 | 459 my $cl_class="cline"; |
devi@23 | 460 my $out_class="output"; |
devi@23 | 461 if ($cl->{"class"}) { |
devi@23 | 462 $cl_class = $cl->{"class"}."_".$cl_class; |
devi@23 | 463 $out_class = $cl->{"class"}."_".$out_class; |
devi@23 | 464 } |
devi@23 | 465 |
devi@23 | 466 my @new_commands; |
devi@23 | 467 my @new_files; |
devi@23 | 468 @new_commands = split (/\s+/, $cl->{"new_commands"}) if defined $cl->{"new_commands"}; |
devi@23 | 469 @new_files = split (/\s+/, $cl->{"new_files"}) if defined $cl->{"new_files"}; |
devi@23 | 470 |
devi@23 | 471 my $output=""; |
devi@23 | 472 if ($Config{"head_lines"} || $Config{"tail_lines"}) { |
devi@23 | 473 # Partialy output |
devi@23 | 474 my @lines = split '\n', $cl->{"output"}; |
devi@23 | 475 # head |
devi@23 | 476 my $mark=1; |
devi@23 | 477 for (my $i=0; $i<= $#lines && $i < $Config{"head_lines"}; $i++) { |
devi@23 | 478 $output .= $lines[$i]."\n"; |
devi@23 | 479 } |
devi@23 | 480 # tail |
devi@23 | 481 my $start=$#lines-$Config{"tail_lines"}+1; |
devi@23 | 482 if ($start < 0) { |
devi@23 | 483 $start=0; |
devi@23 | 484 $mark=0; |
devi@23 | 485 } |
devi@23 | 486 if ($start < $Config{"head_lines"}) { |
devi@23 | 487 $start=$Config{"head_lines"}; |
devi@23 | 488 $mark=0; |
devi@23 | 489 } |
devi@23 | 490 $output .= $Config{"skip_text"}."\n" if $mark; |
devi@23 | 491 for (my $i=$start; $i<= $#lines; $i++) { |
devi@23 | 492 $output .= $lines[$i]."\n"; |
devi@23 | 493 } |
devi@23 | 494 } |
devi@23 | 495 else { |
devi@23 | 496 # Full output |
devi@23 | 497 $output .= $cl->{"output"}; |
devi@23 | 498 } |
devi@23 | 499 #$output .= "^C\n" if ($cl->{"err"} eq "130"); |
devi@23 | 500 |
devi@23 | 501 # |
devi@23 | 502 ## |
devi@23 | 503 ## Начинается собственно вывод |
devi@23 | 504 ## |
devi@23 | 505 # |
devi@23 | 506 |
devi@23 | 507 # <command> |
devi@23 | 508 |
devi@23 | 509 my ($sec,$min,$hour,$day,$mon,$year,$wday,$yday,$isdst) = localtime($cl->{time}); |
devi@31 | 510 $Stat{FirstCommand} = $cl->{time} unless $Stat{FirstCommand}; |
devi@31 | 511 $Stat{LastCommand} = 0 unless defined $Stat{LastCommand}; |
devi@31 | 512 $Stat{TotalTime} += $cl->{time} - $Stat{LastCommand} |
devi@31 | 513 if $cl->{time} - $Stat{LastCommand} < $Config{stat_inactivity_interval}; |
devi@31 | 514 $Stat{LastCommand} = $cl->{time}; |
devi@31 | 515 $Stat{TotalCommands} = 0 unless $Stat{TotalCommands}; |
devi@31 | 516 $Stat{TotalCommands}++; |
devi@31 | 517 |
devi@23 | 518 # Добавляем спереди 0 для удобочитаемости |
devi@23 | 519 $min = "0".$min if $min =~ /^.$/; |
devi@23 | 520 $hour = "0".$hour if $hour =~ /^.$/; |
devi@23 | 521 $sec = "0".$sec if $sec =~ /^.$/; |
devi@23 | 522 |
devi@23 | 523 $class=$cl->{"out_class"}; |
devi@23 | 524 $class =~ s/output$//; |
devi@23 | 525 |
devi@31 | 526 $Stat{ErrorCommands}++ |
devi@31 | 527 if $class =~ /wrong/; |
devi@23 | 528 |
devi@23 | 529 $Result{"body"} .= "<tr class='command'>\n"; |
devi@23 | 530 |
devi@23 | 531 |
devi@23 | 532 # DAY CHANGE |
devi@23 | 533 if ( $last_day ne $day) { |
devi@23 | 534 #$Result{"body"} .= "<td colspan='6'><p></p><h3>День ",$day,"</h4></td></tr><tr>"; |
devi@23 | 535 $Result{"body"} .= "<td colspan='6'><p></p><h3 id='day$day'>".$Day_Name[$wday]."</h4></td></tr><tr>"; |
devi@31 | 536 push @toc, "<a href='#day$day'>".$Day_Name[$wday]."</a>\n"; |
devi@23 | 537 $last_day=$day; |
devi@23 | 538 } |
devi@23 | 539 |
devi@23 | 540 # CONSOLE CHANGE |
devi@23 | 541 if ( $last_tty ne $cl->{"tty"}) { |
devi@32 | 542 my $host; |
devi@32 | 543 #$host = $Sessions{$cl->{local_session_id}}->{user}."@".$Sessions{$cl->{local_session_id}}->{hostname}; |
devi@32 | 544 $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 | 545 $last_tty=$cl->{"tty"}; |
devi@23 | 546 } |
devi@23 | 547 |
devi@23 | 548 # TIME |
devi@23 | 549 if ($Config{"show_time"} =~ /^y/i) { |
devi@23 | 550 $Result{"body"} .= "<td valign='top' class='time' width='$Config{time_width}'><pre>". |
devi@23 | 551 $hour. ":". $min. ":". $sec. |
devi@23 | 552 "</td>"; |
devi@23 | 553 } else { |
devi@23 | 554 $Result{"body"} .= "<td width='0'/>" |
devi@23 | 555 } |
devi@23 | 556 |
devi@23 | 557 # COMMAND |
devi@23 | 558 $Result{"body"} .= "<td class='script'>\n"; |
devi@23 | 559 $Result{"body"} .= "<pre class='${class}cline'>\n"; |
devi@31 | 560 my $cline = $cl->{"prompt"}.$cl->{"cline"}; |
devi@23 | 561 $cline =~ s/\n//; |
devi@32 | 562 |
devi@32 | 563 #$cline .= "(".$Sessions{$cl->{local_session_id}}.")"; |
devi@32 | 564 |
devi@31 | 565 my $hint = make_comment($cl->{"cline"}); |
devi@31 | 566 $cline = "<div title='$hint'>$cline</div>" if $hint; |
devi@31 | 567 $Result{"body"} .= $cline; |
devi@23 | 568 $Result{"body"} .= "</pre>\n"; |
devi@23 | 569 |
devi@23 | 570 my $last_command = $cl->{"last_command"}; |
devi@23 | 571 if (!( |
devi@23 | 572 $Config{"suppress_editors"} =~ /^y/i && grep ($_ eq $last_command, @{$Config{"editors"}}) || |
devi@23 | 573 $Config{"suppress_pagers"} =~ /^y/i && grep ($_ eq $last_command, @{$Config{"pagers"}}) || |
devi@23 | 574 $Config{"suppress_terminal"}=~ /^y/i && grep ($_ eq $last_command, @{$Config{"terminal"}}) |
devi@23 | 575 )) { |
devi@23 | 576 |
devi@23 | 577 $Result{"body"} .= "<pre class='".$cl->{out_class}."'>"; |
devi@23 | 578 $Result{"body"} .= $output; |
devi@23 | 579 $Result{"body"} .= "</pre>\n"; |
devi@23 | 580 } |
devi@23 | 581 |
devi@23 | 582 # DIFF |
devi@23 | 583 if ( $Config{"show_diffs"} =~ /^y/i && $cl->{"diff"}) { |
devi@23 | 584 $Result{"body"} .= "<table><tr><td width='5'/><td class='diff'><pre>"; |
devi@23 | 585 $Result{"body"} .= $cl->{"diff"}; |
devi@23 | 586 $Result{"body"} .= "</pre></td></tr></table>"; |
devi@23 | 587 } |
devi@31 | 588 |
devi@31 | 589 #NOTES |
devi@31 | 590 if ( $Config{"show_notes"} =~ /^y/i && $cl->{"note"}) { |
devi@31 | 591 my $note=$cl->{"note"}; |
devi@31 | 592 $note =~ s/\n/<br\/>\n/msg; |
devi@31 | 593 # Ширину пока не используем |
devi@31 | 594 # $Result{"body"} .= "<table width='$Config{note_width}' class='note'>"; |
devi@31 | 595 $Result{"body"} .= "<table class='note'>"; |
devi@31 | 596 $Result{"body"} .= "<tr><td class='note_title'>".$cl->{note_title}."</td></tr>" if $cl->{note_title}; |
devi@31 | 597 $Result{"body"} .= "<tr><td width='100%' class='note_text'>".$note."</td></tr>"; |
devi@31 | 598 $Result{"body"} .= "</table>\n"; |
devi@31 | 599 } |
devi@23 | 600 |
devi@23 | 601 # COMMENT |
devi@23 | 602 if ( $Config{"show_comments"} =~ /^y/i) { |
devi@31 | 603 my $comment = make_comment($cl->{"cline"}); |
devi@23 | 604 if ($comment) { |
devi@23 | 605 $Result{"body"} .= "<table width='$Config{comment_width}'>". |
devi@23 | 606 "<tr><td width='5'/><td>"; |
devi@23 | 607 $Result{"body"} .= "<table class='note' width='100%'>"; |
devi@23 | 608 $Result{"body"} .= $comment; |
devi@23 | 609 $Result{"body"} .= "</table>\n"; |
devi@23 | 610 $Result{"body"} .= "</td></tr></table>"; |
devi@23 | 611 } |
devi@23 | 612 } |
devi@23 | 613 |
devi@23 | 614 # Вывод очередной команды окончен |
devi@23 | 615 $Result{"body"} .= "</td>\n"; |
devi@23 | 616 $Result{"body"} .= "</tr>\n"; |
devi@23 | 617 } |
devi@23 | 618 |
devi@23 | 619 $Result{"body"} .= "</table>\n"; |
devi@23 | 620 |
devi@31 | 621 #$Result{"stat"} = "<hr/>"; |
devi@31 | 622 |
devi@31 | 623 %StatNames = ( |
devi@31 | 624 FirstCommand => "Время первой команды журнала", |
devi@31 | 625 LastCommand => "Время последней команды журнала", |
devi@31 | 626 TotalCommands => "Количество командных строк в журнале", |
devi@32 | 627 ErrorsPercentage => "Процент команд с ненулевым кодом завершения, %", |
devi@31 | 628 TotalTime => "Суммарное время работы с терминалом <sup><font size='-2'>*</font></sup>, час", |
devi@31 | 629 CommandsPerTime => "Количество командных строк в единицу времени, команда/мин", |
devi@31 | 630 CommandsFDistribution => "Частота использования команд", |
devi@31 | 631 CommandsFDistribution => "Частота использования команд", |
devi@31 | 632 RareCommands => "Частота использования этих команд < 0.5%", |
devi@31 | 633 ); |
devi@31 | 634 @StatOrder = ( |
devi@31 | 635 FirstCommand, |
devi@31 | 636 LastCommand, |
devi@31 | 637 TotalCommands, |
devi@31 | 638 ErrorsPercentage, |
devi@31 | 639 TotalTime, |
devi@31 | 640 CommandsPerTime, |
devi@31 | 641 CommandsFDistribution, |
devi@31 | 642 RareCommands, |
devi@31 | 643 ); |
devi@31 | 644 |
devi@31 | 645 # Подготовка статистики к выводу |
devi@31 | 646 # Некоторые значения пересчитываются! |
devi@31 | 647 # Дальше их лучше уже не использовать!!! |
devi@31 | 648 |
devi@31 | 649 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($Stat{FirstCommand}); |
devi@31 | 650 $Stat{FirstCommand} = sprintf "%02i:%02i:%02i %04i-%2i-%2i", $hour, $min, $sec, $year+1900, $mon+1, $mday; |
devi@31 | 651 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($Stat{LastCommand}); |
devi@31 | 652 $Stat{LastCommand} = sprintf "%02i:%02i:%02i %04i-%2i-%2i", $hour, $min, $sec, $year+1900, $mon+1, $mday; |
devi@31 | 653 $Stat{ErrorsPercentage} = sprintf "%5.2f", $Stat{ErrorCommands}*100/$Stat{TotalCommands} |
devi@31 | 654 if $Stat{TotalCommands}; |
devi@31 | 655 $Stat{CommandsPerTime} = sprintf "%5.2f", $Stat{TotalCommands}*60/$Stat{TotalTime} |
devi@31 | 656 if $Stat{TotalTime}; |
devi@32 | 657 $Stat{TotalTime} = sprintf "%5.2f", $Stat{TotalTime}/60/60; |
devi@31 | 658 |
devi@31 | 659 my $total_commands=0; |
devi@31 | 660 for $command (keys %CommandsFDistribution){ |
devi@31 | 661 $total_commands += $CommandsFDistribution{$command}; |
devi@31 | 662 } |
devi@31 | 663 if ($total_commands) { |
devi@31 | 664 for $command (reverse sort {$CommandsFDistribution{$a} <=> $CommandsFDistribution{$b}} keys %CommandsFDistribution){ |
devi@32 | 665 my $command_html; |
devi@31 | 666 my $percentage = sprintf "%5.2f",$CommandsFDistribution{$command}*100/$total_commands; |
devi@31 | 667 if ($percentage < 0.5) { |
devi@31 | 668 my $hint = make_comment($command); |
devi@32 | 669 $command_html = "$command"; |
devi@31 | 670 $command_html = "<span title='$hint' class='hint'>$command_html</span>" if $hint; |
devi@31 | 671 my $command_html = "<tt>$command_html</tt>"; |
devi@31 | 672 $Stat{RareCommands} .= $command_html."<sub><font size='-2'>".$CommandsFDistribution{$command}."</font></sub> , "; |
devi@31 | 673 } |
devi@31 | 674 else { |
devi@31 | 675 my $hint = make_comment($command); |
devi@32 | 676 $command_html = "$command"; |
devi@31 | 677 $command_html = "<span title='$hint' class='hint'>$command_html</span>" if $hint; |
devi@31 | 678 my $command_html = "<tt>$command_html</tt>"; |
devi@31 | 679 $percentage = sprintf "%5.2f",$percentage; |
devi@31 | 680 $Stat{CommandsFDistribution} .= "<tr><td>".$command_html."</td><td>".$CommandsFDistribution{$command}."</td>". |
devi@31 | 681 "<td>|".("="x int($CommandsFDistribution{$command}*100/$total_commands))."| $percentage%</td></tr>"; |
devi@31 | 682 } |
devi@31 | 683 } |
devi@31 | 684 $Stat{CommandsFDistribution} = "<table>".$Stat{CommandsFDistribution}."</table>"; |
devi@32 | 685 $Stat{RareCommands} =~ s/, $// if $Stat{RareCommands}; |
devi@31 | 686 } |
devi@31 | 687 |
devi@23 | 688 $Result{"stat"} .= "<h2 id='stat'>Статистика</h2>"; |
devi@31 | 689 $Result{"stat"} .= "<table>"; |
devi@31 | 690 for my $stat (@StatOrder) { |
devi@32 | 691 $Result{"stat"} .= "<tr valign='top'><td width='300'>".$StatNames{"$stat"}."</td><td>".$Stat{"$stat"}."</td></tr>" |
devi@32 | 692 if $Stat{"$stat"}; |
devi@31 | 693 } |
devi@31 | 694 |
devi@31 | 695 $Result{"stat"} .= "</table>"; |
devi@31 | 696 $Result{"stat"} .= "<font size='-2'>____<br/>*) Интервалы неактивности длительностью ".($Config{stat_inactivity_interval}/60)." минут и более не учитываются</font></br>"; |
devi@31 | 697 |
devi@31 | 698 #$Result{"help"} .= "<hr/>"; |
devi@23 | 699 $Result{"help"} .= "<h2 id='help'>Справка</h2>"; |
devi@23 | 700 $Result{"help"} .= "$Html_Help<br/>"; |
devi@31 | 701 #$Result{"about"} .= "<hr/>"; |
devi@23 | 702 $Result{"about"} .= "<h2 id='about'>О программе</h2>"; |
devi@23 | 703 $Result{"about"} .= "$Html_About"; |
devi@23 | 704 $Result{"footer"} .= "</body>\n"; |
devi@23 | 705 $Result{"footer"} .= "</html>\n"; |
devi@23 | 706 |
devi@31 | 707 $Result{"title"} = "Журнал лабораторных работ"; |
devi@31 | 708 $Result{"title"}.= " -- ".$course_student if $course_student; |
devi@31 | 709 if ($course_date) { |
devi@31 | 710 $Result{"title"}.= " -- ".$course_date; |
devi@31 | 711 $Result{"title"}.= "/".$course_code if $course_code; |
devi@31 | 712 } |
devi@31 | 713 else { |
devi@31 | 714 $Result{"title"}.= " -- ".$course_code if $course_code; |
devi@31 | 715 } |
devi@31 | 716 |
devi@23 | 717 # Заголовок генерируется позже всего |
devi@23 | 718 # Тогда, когда известно уже, что должно быть написано в |
devi@23 | 719 # оглавлении |
devi@23 | 720 $Result{"header"} = <<HEADER; |
devi@23 | 721 <html> |
devi@23 | 722 <head> |
devi@23 | 723 <meta content='text/html; charset=utf-8' http-equiv='Content-Type' /> |
devi@27 | 724 <link rel='stylesheet' href='$Config{frontend_css}' type='text/css'/> |
devi@31 | 725 <title>$Result{title}</title> |
devi@23 | 726 </head> |
devi@23 | 727 <body> |
devi@23 | 728 <script> |
devi@23 | 729 $Html_JavaScript |
devi@23 | 730 </script> |
devi@31 | 731 <h1>Журнал лабораторных работ</h1> |
devi@23 | 732 |
devi@31 | 733 HEADER |
devi@31 | 734 $Result{"header"} .= "<p>" if $course_student || $course_trainer || $course_name || $course_code || $course_date || $course_center; |
devi@31 | 735 $Result{"header"} .= "Выполнил $course_student<br/>" if $course_student; |
devi@31 | 736 $Result{"header"} .= "Проверил $course_trainer <br/>" if $course_trainer; |
devi@31 | 737 $Result{"header"} .= "Курс " if $course_name || $course_code || $course_date; |
devi@31 | 738 $Result{"header"} .= "$course_name " if $course_name; |
devi@31 | 739 $Result{"header"} .= "($course_code)" if $course_code; |
devi@31 | 740 $Result{"header"} .= ", $course_date<br/>" if $course_date; |
devi@31 | 741 $Result{"header"} .= "Учебный центр $course_center <br/>" if $course_center; |
devi@31 | 742 $Result{"header"} .= "</p>" if $course_student || $course_trainer || $course_name || $course_code || $course_date || $course_center; |
devi@23 | 743 |
devi@31 | 744 my $toc = collapse_list (\@toc); |
devi@31 | 745 $Result{"header"} .= <<HEADER; |
devi@23 | 746 <ul> |
devi@23 | 747 <li><a href='#log'>Журнал</a></li> |
devi@23 | 748 <ul>$toc</ul> |
devi@23 | 749 <li><a href='#stat'>Статистика</a></li> |
devi@23 | 750 <li><a href='#help'>Справка</a></li> |
devi@23 | 751 <li><a href='#about'>О программе</a></li> |
devi@23 | 752 </ul> |
devi@23 | 753 |
devi@23 | 754 <h2 id="log">Журнал</h2> |
devi@23 | 755 HEADER |
devi@31 | 756 $Result{"header"} .= "<table id='visibility_form' class='visibility_form'><tr><td><form>\n"; |
devi@23 | 757 for my $element (keys %Elements_Visibility) |
devi@23 | 758 { |
devi@23 | 759 my @e = split /\s+/, $element; |
devi@23 | 760 my $showhide = join "", map { "ShowHide('$_');" } @e ; |
devi@23 | 761 $Result{"header"} .= "<input type='checkbox' name='$e[0]' onclick=\"$showhide\" checked>". |
devi@23 | 762 $Elements_Visibility{$element}. |
devi@23 | 763 "</input><br>\n"; |
devi@23 | 764 } |
devi@23 | 765 |
devi@23 | 766 $Result{"header"} .= "</form></td></tr></table>\n"; |
devi@23 | 767 |
devi@27 | 768 if ($output_filename eq "-") { |
devi@27 | 769 print $Result{"header"}, $Result{"body"}, $Result{"stat"}, $Result{"help"}, $Result{"about"}, $Result{"footer"}; |
devi@27 | 770 } |
devi@27 | 771 else { |
devi@27 | 772 open(OUT, ">", $output_filename) |
devi@27 | 773 or die "Can't open $output_filename for writing\n"; |
devi@27 | 774 print OUT $Result{"header"}, $Result{"body"}, $Result{"stat"}, $Result{"help"}, $Result{"about"}, $Result{"footer"}; |
devi@27 | 775 close(OUT); |
devi@27 | 776 } |
devi@23 | 777 } |
devi@23 | 778 |
devi@23 | 779 |
devi@23 | 780 |
devi@31 | 781 sub collapse_list($) |
devi@31 | 782 { |
devi@31 | 783 my $res = ""; |
devi@31 | 784 for my $elem (@{$_[0]}) { |
devi@31 | 785 if (ref $elem eq "ARRAY") { |
devi@31 | 786 $res .= "<ul>".collapse_list($elem)."</ul>"; |
devi@31 | 787 } |
devi@31 | 788 else |
devi@31 | 789 { |
devi@31 | 790 $res .= "<li>".$elem."</li>"; |
devi@31 | 791 } |
devi@31 | 792 } |
devi@31 | 793 return $res; |
devi@31 | 794 } |
devi@31 | 795 |
devi@23 | 796 |
devi@23 | 797 |
devi@23 | 798 |
devi@23 | 799 sub init_variables |
devi@23 | 800 { |
devi@23 | 801 $Html_Help = <<HELP; |
devi@31 | 802 Для того чтобы использовать LiLaLo, не нужно знать ничего особенного: |
devi@31 | 803 всё происходит само собой. |
devi@31 | 804 Однако, чтобы ведение и последующее использование журналов |
devi@31 | 805 было как можно более эффективным, желательно иметь в виду следующее: |
devi@31 | 806 <ul> |
devi@31 | 807 <li><p> |
devi@31 | 808 В журнал автоматически попадают все команды, данные в любом терминале системы. |
devi@31 | 809 </p></li> |
devi@31 | 810 <li><p> |
devi@31 | 811 Для того чтобы убедиться, что журнал на текущем терминале ведётся, |
devi@31 | 812 и команды записываются, дайте команду w. |
devi@31 | 813 В поле WHAT, соответствующем текущему терминалу, |
devi@31 | 814 должна быть указана программа script. |
devi@31 | 815 </p></li> |
devi@31 | 816 <li><p> |
devi@31 | 817 Команды, код завершения которых отличен от нуля, выделяются цветом. |
devi@31 | 818 Если код завершения команды равен нулю, |
devi@31 | 819 команда была выполнена без ошибок. |
devi@31 | 820 <table> |
devi@31 | 821 <tr class='command'> |
devi@31 | 822 <td class='script'> |
devi@31 | 823 <pre class='wrong_cline'> |
devi@31 | 824 \$ l s-l</pre> |
devi@31 | 825 <pre class='wrong_output'>bash: l: command not found |
devi@31 | 826 </pre> |
devi@31 | 827 </td> |
devi@31 | 828 </tr> |
devi@31 | 829 </table> |
devi@31 | 830 <br/> |
devi@31 | 831 </p></li> |
devi@31 | 832 <li><p> |
devi@31 | 833 Команды, ход выполнения которых был прерван пользователем, выделяются цветом. |
devi@31 | 834 <table> |
devi@31 | 835 <tr class='command'> |
devi@31 | 836 <td class='script'> |
devi@31 | 837 <pre class='interrupted_cline'> |
devi@31 | 838 \$ find / -name abc</pre> |
devi@31 | 839 <pre class='interrupted_output'>find: /home/devi-orig/.gnome2: Keine Berechtigung |
devi@31 | 840 find: /home/devi-orig/.gnome2_private: Keine Berechtigung |
devi@31 | 841 find: /home/devi-orig/.nautilus/metafiles: Keine Berechtigung |
devi@31 | 842 find: /home/devi-orig/.metacity: Keine Berechtigung |
devi@31 | 843 find: /home/devi-orig/.inkscape: Keine Berechtigung |
devi@31 | 844 ^C |
devi@31 | 845 </pre> |
devi@31 | 846 </td> |
devi@31 | 847 </tr> |
devi@31 | 848 </table> |
devi@31 | 849 <br/> |
devi@31 | 850 </p></li> |
devi@31 | 851 <li><p> |
devi@31 | 852 Команды, выполненные с привилегиями суперпользователя, |
devi@31 | 853 выделяются слева красной чертой. |
devi@31 | 854 <table> |
devi@31 | 855 <tr class='command'> |
devi@31 | 856 <td class='script'> |
devi@31 | 857 <pre class='_root_cline'> |
devi@31 | 858 # id</pre> |
devi@31 | 859 <pre class='_root_output'> |
devi@31 | 860 uid=0(root) gid=0(root) Gruppen=0(root) |
devi@31 | 861 </pre> |
devi@31 | 862 </td> |
devi@31 | 863 </tr> |
devi@31 | 864 </table> |
devi@31 | 865 <br/> |
devi@31 | 866 </p></li> |
devi@31 | 867 <li><p> |
devi@31 | 868 Изменения, внесённые в текстовый файл с помощью редактора, |
devi@31 | 869 запоминаются и показываются в журнале в формате ed. |
devi@31 | 870 Строки, начинающиеся символом "<", удалены, а строки, |
devi@31 | 871 начинающиеся символом ">" -- добавлены. |
devi@31 | 872 <table> |
devi@31 | 873 <tr class='command'> |
devi@31 | 874 <td class='script'> |
devi@31 | 875 <pre class='cline'> |
devi@31 | 876 \$ vi ~/.bashrc</pre> |
devi@31 | 877 <table><tr><td width='5'/><td class='diff'><pre>2a3,5 |
devi@31 | 878 > if [ -f /usr/local/etc/bash_completion ]; then |
devi@31 | 879 > . /usr/local/etc/bash_completion |
devi@31 | 880 > fi |
devi@31 | 881 </pre></td></tr></table></td> |
devi@31 | 882 </tr> |
devi@31 | 883 </table> |
devi@31 | 884 <br/> |
devi@31 | 885 </p></li> |
devi@31 | 886 <li><p> |
devi@31 | 887 Для того чтобы получить краткую справочную информацию о команде, |
devi@31 | 888 нужно подвести к ней мышь. Во всплывающей подсказке появится краткое |
devi@31 | 889 описание команды. |
devi@31 | 890 </p></li> |
devi@31 | 891 <li><p> |
devi@31 | 892 Время ввода команды, показанное в журнале, соответствует времени |
devi@31 | 893 <i>начала ввода командной строки</i>, которое равно тому моменту, |
devi@31 | 894 когда на терминале появилось приглашение интерпретатора |
devi@31 | 895 </p></li> |
devi@31 | 896 <li><p> |
devi@31 | 897 Имя терминала, на котором была введена команда, показано в специальном блоке. |
devi@31 | 898 Этот блок показывается только в том случае, если терминал |
devi@31 | 899 текущей команды отличается от терминала предыдущей. |
devi@31 | 900 </p></li> |
devi@31 | 901 <li><p> |
devi@31 | 902 Вывод не интересующих вас в настоящий момент элементов журнала, |
devi@31 | 903 таких как время, имя терминала и других, можно отключить. |
devi@31 | 904 Для этого нужно воспользоваться <a href='#visibility_form'>формой управления журналом</a> |
devi@31 | 905 вверху страницы. |
devi@31 | 906 </p></li> |
devi@31 | 907 <li><p> |
devi@31 | 908 Небольшие комментарии к командам можно вставлять прямо из командной строки. |
devi@31 | 909 Комментарий вводится прямо в командную строку, после символов #^ или #v. |
devi@31 | 910 Символы ^ и v показывают направление выбора команды, к которой относится комментарий: |
devi@31 | 911 ^ - к предыдущей, v - к следующей. |
devi@31 | 912 Например, если в командной строке было введено: |
devi@31 | 913 <pre class='cline'> |
devi@31 | 914 \$ whoami |
devi@31 | 915 </pre> |
devi@31 | 916 <pre class='output'> |
devi@31 | 917 user |
devi@31 | 918 </pre> |
devi@31 | 919 <pre class='cline'> |
devi@31 | 920 \$ #^ Интересно, кто я? |
devi@31 | 921 </pre> |
devi@31 | 922 в журнале это будет выглядеть так: |
devi@31 | 923 |
devi@31 | 924 <pre class='cline'> |
devi@31 | 925 \$ whoami |
devi@31 | 926 </pre> |
devi@31 | 927 <pre class='output'> |
devi@31 | 928 user |
devi@31 | 929 </pre> |
devi@31 | 930 <table class='note'><tr><td width='100%' class='note_text'> |
devi@31 | 931 <tr> <td> Интересно, кто я?<br/> </td></tr></table> |
devi@31 | 932 </p></li> |
devi@31 | 933 <li><p> |
devi@31 | 934 Если комментарий содержит несколько строк, |
devi@31 | 935 его можно вставить в журнал следующим образом: |
devi@31 | 936 <pre class='cline'> |
devi@31 | 937 \$ whoami |
devi@31 | 938 </pre> |
devi@31 | 939 <pre class='output'> |
devi@31 | 940 user |
devi@31 | 941 </pre> |
devi@31 | 942 <pre class='cline'> |
devi@31 | 943 \$ cat > /dev/null #^ Интересно, кто я? |
devi@31 | 944 </pre> |
devi@31 | 945 <pre class='output'> |
devi@31 | 946 Программа whoami выводит имя пользователя, под которым |
devi@31 | 947 мы зарегистрировались в системе. |
devi@31 | 948 - |
devi@31 | 949 Она не может ответить на вопрос о нашем назначении |
devi@31 | 950 в этом мире. |
devi@31 | 951 </pre> |
devi@31 | 952 В журнале это будет выглядеть так: |
devi@31 | 953 <table> |
devi@31 | 954 <tr class='command'> |
devi@31 | 955 <td class='script'> |
devi@31 | 956 <pre class='cline'> |
devi@31 | 957 \$ whoami</pre> |
devi@31 | 958 <pre class='output'>user |
devi@31 | 959 </pre> |
devi@31 | 960 <table class='note'><tr><td class='note_title'>Интересно, кто я?</td></tr><tr><td width='100%' class='note_text'> |
devi@31 | 961 Программа whoami выводит имя пользователя, под которым<br/> |
devi@31 | 962 мы зарегистрировались в системе.<br/> |
devi@31 | 963 <br/> |
devi@31 | 964 Она не может ответить на вопрос о нашем назначении<br/> |
devi@31 | 965 в этом мире.<br/> |
devi@31 | 966 </td></tr></table> |
devi@31 | 967 </td> |
devi@31 | 968 </tr> |
devi@31 | 969 </table> |
devi@31 | 970 Для разделения нескольких абзацев между собой |
devi@31 | 971 используйте символ "-", один в строке. |
devi@31 | 972 <br/> |
devi@31 | 973 </p></li> |
devi@31 | 974 <li><p> |
devi@31 | 975 Комментарии, не относящиеся непосредственно ни к какой из команд, |
devi@31 | 976 добавляются точно таким же способом, только вместо симолов #^ или #v |
devi@31 | 977 нужно использовать символы #= |
devi@31 | 978 </p></li> |
devi@31 | 979 </ul> |
devi@23 | 980 HELP |
devi@23 | 981 |
devi@23 | 982 $Html_About = <<ABOUT; |
devi@23 | 983 <p> |
devi@23 | 984 LiLaLo (L3) расшифровывается как Live Lab Log.<br/> |
devi@29 | 985 Программа разработана для повышения эффективности обучения Unix/Linux-системам.<br/> |
devi@23 | 986 (c) Игорь Чубин, 2004-2005<br/> |
devi@23 | 987 </p> |
devi@23 | 988 ABOUT |
devi@23 | 989 $Html_About.='$Id$ </p>'; |
devi@23 | 990 |
devi@23 | 991 $Html_JavaScript = <<JS; |
devi@23 | 992 function getElementsByClassName(Class_Name) |
devi@23 | 993 { |
devi@23 | 994 var Result=new Array(); |
devi@23 | 995 var All_Elements=document.all || document.getElementsByTagName('*'); |
devi@23 | 996 for (i=0; i<All_Elements.length; i++) |
devi@23 | 997 if (All_Elements[i].className==Class_Name) |
devi@23 | 998 Result.push(All_Elements[i]); |
devi@23 | 999 return Result; |
devi@23 | 1000 } |
devi@23 | 1001 function ShowHide (name) |
devi@23 | 1002 { |
devi@23 | 1003 elements=getElementsByClassName(name); |
devi@23 | 1004 for(i=0; i<elements.length; i++) |
devi@23 | 1005 if (elements[i].style.display == "none") |
devi@23 | 1006 elements[i].style.display = ""; |
devi@23 | 1007 else |
devi@23 | 1008 elements[i].style.display = "none"; |
devi@23 | 1009 //if (elements[i].style.visibility == "hidden") |
devi@23 | 1010 // elements[i].style.visibility = "visible"; |
devi@23 | 1011 //else |
devi@23 | 1012 // elements[i].style.visibility = "hidden"; |
devi@23 | 1013 } |
devi@23 | 1014 function filter_by_output(text) |
devi@23 | 1015 { |
devi@23 | 1016 |
devi@23 | 1017 var jjj=0; |
devi@23 | 1018 |
devi@23 | 1019 elements=getElementsByClassName('command'); |
devi@23 | 1020 for(i=0; i<elements.length; i++) { |
devi@23 | 1021 subelems = elements[i].getElementsByTagName('pre'); |
devi@23 | 1022 for(j=0; j<subelems.length; j++) { |
devi@23 | 1023 if (subelems[j].className = 'output') { |
devi@23 | 1024 var str = new String(subelems[j].nodeValue); |
devi@23 | 1025 if (jjj != 1) { |
devi@23 | 1026 alert(str); |
devi@23 | 1027 jjj=1; |
devi@23 | 1028 } |
devi@23 | 1029 if (str.indexOf(text) >0) |
devi@23 | 1030 subelems[j].style.display = "none"; |
devi@23 | 1031 else |
devi@23 | 1032 subelems[j].style.display = ""; |
devi@23 | 1033 |
devi@23 | 1034 } |
devi@23 | 1035 |
devi@23 | 1036 } |
devi@23 | 1037 } |
devi@23 | 1038 |
devi@23 | 1039 } |
devi@23 | 1040 JS |
devi@23 | 1041 |
devi@23 | 1042 %Search_Machines = ( |
devi@23 | 1043 "google" => { "query" => "http://www.google.com/search?q=" , |
devi@28 | 1044 "icon" => "$Config{frontend_google_ico}" }, |
devi@23 | 1045 "freebsd" => { "query" => "http://www.freebsd.org/cgi/man.cgi?query=", |
devi@28 | 1046 "icon" => "$Config{frontend_freebsd_ico}" }, |
devi@23 | 1047 "linux" => { "query" => "http://man.he.net/?topic=", |
devi@28 | 1048 "icon" => "$Config{frontend_linux_ico}"}, |
devi@23 | 1049 "opennet" => { "query" => "http://www.opennet.ru/search.shtml?words=", |
devi@28 | 1050 "icon" => "$Config{frontend_opennet_ico}"}, |
devi@23 | 1051 "local" => { "query" => "http://www.freebsd.org/cgi/man.cgi?query=", |
devi@28 | 1052 "icon" => "$Config{frontend_local_ico}" }, |
devi@23 | 1053 |
devi@23 | 1054 ); |
devi@23 | 1055 |
devi@23 | 1056 %Elements_Visibility = ( |
devi@23 | 1057 "note" => "замечания", |
devi@23 | 1058 "diff" => "редактор", |
devi@23 | 1059 "time" => "время", |
devi@23 | 1060 "ttychange" => "терминал", |
devi@23 | 1061 "wrong_output wrong_cline wrong_root_output wrong_root_cline" |
devi@23 | 1062 => "команды с ошибками", |
devi@23 | 1063 "interrupted_output interrupted_cline interrupted_root_output interrupted_root_cline" |
devi@23 | 1064 => "прерванные команды", |
devi@23 | 1065 "tab_completion_output tab_completion_cline" |
devi@23 | 1066 => "продолжение с помощью tab" |
devi@23 | 1067 ); |
devi@23 | 1068 |
devi@23 | 1069 @Day_Name = qw/ Воскресенье Понедельник Вторник Среда Четверг Пятница Суббота /; |
devi@23 | 1070 @Month_Name = qw/ Январь Февраль Март Апрель Май Июнь Июль Август Сентябрь Октябрь Ноябрь Декабрь /; |
devi@23 | 1071 @Of_Month_Name = qw/ Января Февраля Марта Апреля Мая Июня Июля Августа Сентября Октября Ноября Декабря /; |
devi@23 | 1072 } |
devi@23 | 1073 |