Prabhu Gurumurthy wrote:
> 
> Hi,

Hello,

> I have question, in my script i have lines as below:
> 
> open(PASSFILE, "+>>passfile") || die "Cannot open file: $!\n";
>   print PASSFILE "$usname[$i] : $pasname[$i]\n";
> close(PASSFILE);
> and they work fine,
> and in the "passfile i have
> 
> root : root123
> 
> But if i want to read the lines from the passfile how do i do it?

while (
my($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$dir,$shell,$expire) =
getpwent ) {
    print "$name\n";
    }


> In another perl script i want to verify whether the user is in the file or
> not?
> 
> ./verify root

my $name = 'root';
if ( defined getpwnam $name ) {
    print "The user '$name' exists.\n";
    }
else {
    print "The user '$name' does not exist.\n";
    }


> i want to know how to match the command line argument with the pattern
> present in the file.
> 
> i know
> $user = $ARGV[0];
> open(FILE, "passfile) || die "Cannot open file: $!\n";
> while(<FILE>) {
> 
> what should come here for me to verify whether the user is present in the
> passfile of not?
> 
> i tried split, grep, but could not find the correct way to put that in the
> script.


perldoc -f getpwent
perldoc -f getpwnam
perldoc -f getpwuid
perldoc -f setpwent



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to