unruly
06-08-2002, 06:50 PM
well, I'm trying to make a program to get a username from the user, and use a hash to tell them what shell that user uses... useless, but it's for my own edification.... here's what I have so far. Right now I'm having problems getting info into/out of a hash....
#!/usr/bin/perl -w
sub getUserShell{
@etcPasswd = `cut -d: -f 1,7 /etc/passwd`; # easier than trying to figure out split ;)
foreach(@etcPasswd){
($user, $shell) = split(/:/, $_, 2);
chomp($user, $shell);
%userShell = { "$user" => "$shell" };
}
#return (print $userShell{"unruly"});
}
&getUserShell;
#!/usr/bin/perl -w
sub getUserShell{
@etcPasswd = `cut -d: -f 1,7 /etc/passwd`; # easier than trying to figure out split ;)
foreach(@etcPasswd){
($user, $shell) = split(/:/, $_, 2);
chomp($user, $shell);
%userShell = { "$user" => "$shell" };
}
#return (print $userShell{"unruly"});
}
&getUserShell;