#!/usr/bin/perl -w use Tk; use Tk::DialogBox; use strict; my($main,$Edit); $main=MainWindow->new(-title => 'FINGER'); $main->Label(-text => 'Finger application')->pack; $main->Label(-text => 'Enter user name')->pack; $Edit=$main->Entry(-width => 20)->pack; $main->Button(-text => 'Show Info', -command => \&ShowInfo)->pack(-side => 'left'); $main->Button(-text => 'Exit', -command => [$main => 'destroy'] )->pack; MainLoop; sub ShowInfo { my($InfoWindow,$request,$found,$User,$GECOS,$HomeDir,$Shell,$RealName,$HomePhone); $InfoWindow=$main->DialogBox(-title => 'User Information', -buttons => ["OK"]); open (FL,"/etc/passwd"); $request=$Edit->get; while () { chomp(); ($User,$GECOS,$HomeDir,$Shell)=(split /:/)[0,4,5,6]; ($RealName,$HomePhone)=(split(/,/,$GECOS))[0,3]; if ($User eq $request) { $found=1; last; } } if($found==1) { $InfoWindow->add("Label", -text => "LinuxUser: $User")->pack; $InfoWindow->add("Label", -text => "User name: $RealName")->pack; $InfoWindow->add("Label", -text => "Home phone: $HomePhone")->pack; $InfoWindow->add("Label", -text => "Home directory: $HomeDir")->pack; $InfoWindow->add("Label", -text => "User shell: $Shell")->pack; }else{ $InfoWindow->add("Label", -text => " There is no such user ")->pack; $InfoWindow->add("Label", -text => "in your /etc/passwd file")->pack; } $InfoWindow->Show(); $InfoWindow->destroy; close(FL); }