Link to home
Start Free TrialLog in
Avatar of bsufs
bsufs

asked on

finger command

Is it possible to send a finger command via a Perl script?  What I'd like to do is send the command and then display the results in a web browser.
Avatar of ozo
ozo
Flag of United States of America image

`finger $user`
Avatar of ecw
ecw

$res = `finger "$user"`;

If you want a really technical question, you can open the socket connection to the
intended host, send a query, receive a reply and display it.  This way you can customize the error messages.  Finger port is 79.
ASKER CERTIFIED SOLUTION
Avatar of tim_lbi
tim_lbi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Doesn't
   open(F,"|/usr/bin/finger bla");
open a pipe *to* finger (which is wrong), not a pipe from finger to capture its results?

Not to mention that
 print STDOUT <F>;
is a bad way to print the results of the finger to the browser, since the results could contain characters such as < > and & which have special meanings in html and thus need to be translated into the html equivalents, e.g.
 $res =~ s/</&lt;/g;
print STDOUT <F> was just an example.
while(<F>)
{ $_ =~ s/</&lt;/g; $_=~ s/>/&gt;/g; print "Line: $_"; }
You may do what you want with the output...
The part with 'pipe to finger' is a bit strange...What you write to F is STDIN on finger, and what you read from F is STDOUT of finger. The pipe is 2 way communication...

Tim