I'm trying to check if a user exists in /etc/passwd on a remote

Here is my code, tried to do this 2 different ways, neither way will work.
Any advice ?

@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}

$userid = $FORM{userid};
$username = $FORM{username};
#chomp ($userid);
print $userid;

@listusers = `ssh -i ~/.ssh/whoisit <ipaddress> -l <userid> 'cat
/etc/passwd'`;
print "<p>";
foreach $file (@listusers) {
        print "$file";

                #              if ($userid =~ /a.*/) {
                                if ( $userid  =~ /^$file./ ) {
                                        print "exists";
                                        ## yes, it matches
                                                } else {
                                                print " not exist";
                                        #       print " does not exist";
                                            ## no, it doesn't
                                        }







        print "<br>";
        }

print "<p>";
foreach ($i = 0; $i<$#listusers; $i++) {

#       if ($userid =~ /^$listusers[$i]/) {
#       if $listusers[$i] =~ /a/) {
        print "$listusers[$i]";
        print "<br>";
                if ( $userid =~ /^$listusers[$i]/i ) {

                print "exists ";
                    ## yes, it matches
                        } else {
                        print " does not exist ";
    ## no, it doesn't
}
}




-- 
http://www.e-securenetworks.net
http://www.shopper-holic.com
http://www.planet247.net
http://www.auction-holic.com

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

Reply via email to