3 # Copyright Andreas Schlapbach, schlpbch@iam.unibe.ch, 2001
4 # http://iamexwiwww.unibe.ch/studenten/kfinger
6 # Touch at your own risk.
9 # Highlight mail addresses or url
11 $mails = '<A HREF="mailto:';
16 # Highlight various information, configurable via the CSS file,
18 $finger = '<CODE class="finger">';
19 $domainName = '<CODE class="domainName">';
20 $ipNumber = '<CODE class="ipNumber">';
21 $os = '<CODE class="os">';
22 $username = '<CODE class="username">';
23 $directory = '<CODE class="directory">';
24 $shell = '<CODE class="shell">';
25 $notLoggedIn = '<CODE class="Login">';
26 $loggedIn = '<CODE class="noLogin">';
27 $newMail = '<CODE class="newMail">';
28 $plan = '<CODE class="plan">';
29 $noNewMail = '<CODE class="noNewMail">';
30 $noPlan = '<CODE class="noPlan">';
33 # Those names get skipped, so if there's a user with such a name, bad luck.
35 @keywords=('Welcome','Login','finger','No');
36 $keywordlist = join '|', @keywords;
38 $FINGERCMD = "$ARGV[0]"; # The complete path to the finger cmd
39 $CSSFILE = "$ARGV[1]"; # The complete path to the CSS file
40 $REFRESHRATE = "$ARGV[2]"; # The intervals in seconds until the page gets updated
41 $HOST = "$ARGV[3]"; # host name
42 $USER = "$ARGV[4]"; # user name
55 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
58 <meta http-equiv="refresh" content="$REFRESHRATE">
59 <TITLE>finger $USER\@$HOST</TITLE>
60 <LINK type="text/css" rel="stylesheet" href="file:$CSSFILE">
63 <TABLE class="mainTable" cellspacing="0">
66 <H1>finger $USER\@$HOST</H1>
71 <TABLE class="courierText" cellpadding="0" cellspacing="2">
74 # Run finger command and save it into a buffer
76 open(F
, "-|") || exec $FINGERCMD, "$USER\@$HOST";
80 # Do highlighting using perl regular expressions on every line received.
81 # Order is important here.
83 foreach $output (@lines)
85 $output =~ s/((\w)+\@((\w)+(.))*(\w)+)/$mails$1$urlspace$1$urlend/gi; # Highlight email address
86 $output =~ s/((http|ftp)(:\/\/)(\S
)+)/$urls$1$urlspace$1$urlend/gi; # Highlight urls
87 $output =~ s/((\d)+\.(\d)+\.(\d)+\.(\d)+)/$ipNumber$1$close/gi; # Highlight IP number
88 $output =~ s/((\w)+\.(\w)+\.(\w|-)+\s)/$domainName$1$close/gi; # Highlight domain name (\s is important)
89 $output =~ s/(finger:)/$finger$1$close/gim; # Highlight finger
90 $output =~ s/(Linux)/$os$1$close/gim; # Highlight Linux
91 if ($USER) # is $USER nil ?
93 $output =~ s/^Login:\s*(\w*)/Login: $mails$1\@$HOST$urlspace$1$urlend/gi;
94 $output =~ s/^Login Name:\s*(\w*)/Login Name:$mails$1\@$HOST$urlspace$1$urlend/gi;
95 $output =~ s/Name:(((\s*)(\w+))+\n)/Name:$username$1$close\n/gi; # Linux
96 $output =~ s/In real life:(((\s*)(\w+))+\n)/In real life:$username$1$close\n/gi; # Solaris
97 $output =~ s/^Directory:((\s*)(\/(\w)+)+)/Directory
:$directory$1$close/gi
; # Highlight Directory
98 $output =~ s/Shell:((\s*)(\/(\w)+)+)/Shell
:$shell$1$close/gi
; # Highlight Shell
99 $output =~ s/(not presently logged)/$notLoggedIn$1$close/gi;
100 $output =~ s/con (\w*)/con $loggedIn$1$close/gi;
101 $output =~ s/^(New mail)/$newMail$1$close/gi;
102 $output =~ s/^(No mail.)/$noNewMail$1$close/gim;
103 $output =~ s/^(Plan:)/$plan$1$close/gi;
104 $output =~ s/^(No plan.)/$noPlan$1$close/gim;
108 $output =~ s/^(\w+)/$mails$1\@$HOST$urlspace$1$urlend/m unless ($output =~ m/$keywordlist/m);
110 # line consists of white space only?
111 if ($output =~ m/\S/gi)
113 print " <TR><TD><PRE>$output</PRE></TD></TR>\n";
117 print " <TR><TD><PRE> </PRE></TD></TR>\n";
124 # Finger-Talk options
126 if ($USER) # is $USER nil ?
131 <TH class="commandText" colspan="2">
132 <A HREF='finger://$USER\@$HOST'>finger</A>
139 print <<HostQueryHead;
141 <TABLE class="courierText" cellpadding="0" cellspacing="2">
144 @lines = split /^/m, $buffer;
145 foreach $output2 (@lines)
147 if ($output2 =~ m/^(\w+)/gi and not ($output2 =~ m/$keywordlist/m))
150 print " <TR><TD><PRE><A HREF='finger://$USER\@$HOST'>finger</A>\n</PRE></TD></TR>\n";
151 # - <A HREF='talk://$USER\@$HOST'>talk</A>\n</PRE></TD></TR>\n";
155 print " <TR><TD><PRE> </PRE></TD></TR>\n";
159 print <<HostQueryTail;
170 <TH class="niceText">refresh rate: $REFRESHRATE seconds.</TH>