> -----Original Message----- > From: Rob.Savino [mailto:[EMAIL PROTECTED] > Sent: Wednesday, November 09, 2005 1:50 PM > To: beginners@perl.org > Subject: help with matching > > > I'm working on a simple script to get a list of users who do not exist > > while (<>) { > $user = system("echo $_"); > $result = system("dsquery user -samID $_"); > } > if (!$result) {
'system' will always return the exit status of whatever program you called. So $result is always set (zero _and_ non-zero statuses). Basically, if it fails or succeeds your script will output the user name. You'll need to check the status that $result is set to and code for that. > print "$user\n"; > } > Four things to note: 1. use warnings; 2. use strict; 3. Scope your variables 4. Search CPAN for a module that will help with MS Active Directory queries instead of performing system calls. You'll be happy you did. ry > Here is my problem, > > dsquery user -samID should return nothing if a user does not exist. I > was hoping the script would print $user only if there was no $result > from dsquery user -samID. However, not only does it print every $user > regardless of the was not $result, it also prints every $result. > > Can someone tell me why this is? > > Thanks, > > Rob > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>