I am attempting to redirect the output from a system 
command to a file, however when I print it only goes to 
stdout and I get 0's in the file.  The first loop works 
find the second is what is failing.  I have even tried 
redirecting within the system function ( system " 
command > /home/file") that doesn't work either.

Any comments/suggestions are appreciated.

Thanks for your help

Grant

sub lastlog {
    open IN, "/etc/passwd";
    open OUT, ">/home/ghansen/lastlog.txt";
    select OUT;
    while (<IN>) {
        my @passwd = split /:/;
        my $userid = ($passwd[0]);
        print "$userid \n";
    }
    open IN, "/home/ghansen/lastlog.txt" or die "Cannot 
Create Output file";
    open OUT, ">/home/ghansen/lastlog.out" or 
die "Cannot Create Output file";
    select OUT;
           while (<IN>) {
            chomp();
            $user = $_;
            $output = system "last $user | head -1";
            print "$output \n";

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

Reply via email to