develooper Front page | perl.beginners | Postings from July 2003

Can't get the regular expression right

Thread Next
From:
Distribution Lists
Date:
July 9, 2003 10:14
Subject:
Can't get the regular expression right
Message ID:
9611.205.182.74.254.1057770831.squirrel@www.veronicas-therapy.com
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

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About