I'm trying to search the /etc/passwd file for a username that is inputted by the user but I'm unsure on the syntax for the if statement. My current code is
print "Username?";
$username = <STDIN>;
open (PASSWD, '/etc/passwd')
while (<PASSWD>);
if (PASSWD ((split(/:/)[0] =~ $username)) {
print ((split(/:/)[5]), "\n");
}
close (PASSWD);
Something is wrong with the syntax and I'm having difficulty finding the correct way despite searching stack and google, any help would be appreciated.
Aucun commentaire:
Enregistrer un commentaire