##!/usr/bin/perl # # Copyright Andreas Schlapbach, schlpbch@iam.unibe.ch, 2001 # http://iamexwiwww.unibe.ch/studenten/kfinger # # Touch at your own risk. # Highlight mail addresses or url $mails = '/>/g; $USER =~ s/&/&/g; $USER =~ s//>/g; # HTML Header print < finger $USER\@$HOST \n"; # Finger-Talk options if ($USER) # is $USER nil ? { print < UserQuery } else { print <

finger $USER\@$HOST

HTMLHeader # Run finger command and save it into a buffer open(F, "-|") || exec $FINGERCMD, "$USER\@$HOST"; @lines = ; close(F); # Do highlighting using perl regular expressions on every line received. # Order is important here. foreach $output (@lines) { $output =~ s/((\w)+\@((\w)+(.))*(\w)+)/$mails$1$urlspace$1$urlend/gi; # Highlight email address $output =~ s/((http|ftp)(:\/\/)(\S)+)/$urls$1$urlspace$1$urlend/gi; # Highlight urls $output =~ s/((\d)+\.(\d)+\.(\d)+\.(\d)+)/$ipNumber$1$close/gi; # Highlight IP number $output =~ s/((\w)+\.(\w)+\.(\w|-)+\s)/$domainName$1$close/gi; # Highlight domain name (\s is important) $output =~ s/(finger:)/$finger$1$close/gim; # Highlight finger $output =~ s/(Linux)/$os$1$close/gim; # Highlight Linux if ($USER) # is $USER nil ? { $output =~ s/^Login:\s*(\w*)/Login: $mails$1\@$HOST$urlspace$1$urlend/gi; $output =~ s/^Login Name:\s*(\w*)/Login Name:$mails$1\@$HOST$urlspace$1$urlend/gi; $output =~ s/Name:(((\s*)(\w+))+\n)/Name:$username$1$close\n/gi; # Linux $output =~ s/In real life:(((\s*)(\w+))+\n)/In real life:$username$1$close\n/gi; # Solaris $output =~ s/^Directory:((\s*)(\/(\w)+)+)/Directory:$directory$1$close/gi; # Highlight Directory $output =~ s/Shell:((\s*)(\/(\w)+)+)/Shell:$shell$1$close/gi; # Highlight Shell $output =~ s/(not presently logged)/$notLoggedIn$1$close/gi; $output =~ s/con (\w*)/con $loggedIn$1$close/gi; $output =~ s/^(New mail)/$newMail$1$close/gi; $output =~ s/^(No mail.)/$noNewMail$1$close/gim; $output =~ s/^(Plan:)/$plan$1$close/gi; $output =~ s/^(No plan.)/$noPlan$1$close/gim; } else { $output =~ s/^(\w+)/$mails$1\@$HOST$urlspace$1$urlend/m unless ($output =~ m/$keywordlist/m); } # line consists of white space only? if ($output =~ m/\S/gi) { print " \n"; } else { print " \n"; } } print "
$output
  
\n"; print "
finger
HostQueryHead @lines = split /^/m, $buffer; foreach $output2 (@lines) { if ($output2 =~ m/^(\w+)/gi and not ($output2 =~ m/$keywordlist/m)) { $USER = $&; print " \n"; # - talk\n\n"; } else { print " \n"; } } print < HostQueryTail } # HTMLTail print <
finger\n
  
refresh rate: $REFRESHRATE seconds.
HTMLTail