Capture command output into list? 
Author Message
 Capture command output into list?

I'm attempting to capture the output from the "groups" command and
compare each value one at a time.
When I run this code, the foreach loop is only run once and $g is
printed as a single string of group names.

#!/usr/local/bin/perl
    $name = "guest";



        if ($g eq "nobody") {
            print "$name is a member of $g\n";
        }
    }

What am I doing wrong??

Dennis



Sat, 05 Jan 2002 03:00:00 GMT  
 Capture command output into list?

Quote:
> I'm attempting to capture the output from the "groups" command and
> compare each value one at a time.
> When I run this code, the foreach loop is only run once and $g is
> printed as a single string of group names.

> #!/usr/local/bin/perl
>     $name = "guest";



>         if ($g eq "nobody") {
>             print "$name is a member of $g\n";
>         }
>     }

> What am I doing wrong??

you're making a list of one element and assigning it to groups.
you need to split up the result of backticks, perhaps using split().

--
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>



Sat, 05 Jan 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. capturing command line error or output from `<command>`

2. capturing output of FILEHANDLE "| command"

3. capturing output from a remote command (how?)

4. Capturing System Command Output with Perl on Windows/Apache

5. capturing output of executed system command

6. capturing output of piped commands

7. Help with Piped command, capturing output

8. Capturing output of a system command

9. help with capturing output of open command

10. How do I capture output from a print command

11. Capturing command output in Perl

12. Capturing Command Line Output

 

 
Powered by phpBB® Forum Software