Discussion Locked

perl - html

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

This question is only for the perl side.

Assuming this is a form with only ONE label and ONE input box. The label says: "Enter loginname" and the box is a of type "input".

How do I write a short perl script that would take the login name from one input box and see if the user is in the /etc/passwd file. If it is, display the last time he/she was logged on using the "last" command.

If the user is NOT there,in the /etc/passwd file, just display where they came from (ip address) REMOTEHOST?

Can someone help?

Thanks.
Raf

3 replies

by denis77

#!/usr/bin/perl
my %FORM = &get_form;
my $username = $FORM{username};

my $uid = getpwnam($username);

print "Content-type: text/html\n\n";

if ( $uid ) {
print `last -n 1 $username`;
} else {
print "remote host = $ENV{REMOTE_ADDR}";}

This discussion is closed to new replies.