[TriLUG] possible awk/grep question

Engle, Victor Victor.Engle at netapp.com
Thu Jan 17 14:29:44 EST 2008


 
> 
> but I'd rather not write anything to an intermediary file.
> 
> In my first attempt, the "done" line becomes
> 
> done) < `ssh $machine cat /etc/passwd`
> 
> when I get the error "ambiguous redirect".
> 
> It's been ages since I've seen that message and google isn't 
> any help. I can't figure out how to make the output of
> 
> ssh $machine cat /etc/passwd
> 
> look like a file.
> 
> Any suggestions?
> 

#!/usr/bin/perl -w

$machine = 'frosty';
open(PW,"ssh $machine \"cat /etc/passwd\"|")
         or die "remote command failed ($!)\n";

while ( $pwline = <PW> ) {
        @pwline = split(/:/,$pwline);
        print $pwline if ($pwline[3] == 500);
}

close(PW);

exit(0);



More information about the TriLUG mailing list