#----------------------------- |
print textfield ( "SEARCH" ); |
# previous SEARCH value is the default |
#----------------------------- |
# download the following standalone program |
#!/usr/bin/perl -wT |
# who.cgi - run who(1) on a user and format the results nicely |
$ENV {IFS}= '' ; |
$ENV {PATH}= '/bin:/usr/bin' ; |
use CGI qw ( :standard ); |
# print search form |
print header(), start_html ( "Query Users" ), h1 ( "Search" ); |
print start_form(), p ( "Which user?" , textfield ( "WHO" ) ); |
submit(), end_form(); |
# print results of the query if we have someone to look for |
$name = param ( "WHO" ); |
if ( $name ) |
{ |
print h1 ( "Results" ); |
$html = '' ; |
# call who and build up text of response |
foreach ( `who` ) |
{ |
next unless /^ $name \s/o; |
# only lines matching $name |
s/&/& |
/g; |
# escape HTML |
s/</< |
/g; |
s/>/> |
/g; |
$html .= $_ ; |
} |
# nice message if we didn't find anyone by that name |
$html = $html || "$name is not logged in" ; |
print pre( $html ); |
} |
print end_html(); |
#----------------------------- |
by: 发表于:2017-09-15 16:57:18 顶(0) | 踩(0) 回复
??
回复评论