Catching System output from Perl

I’m too lazy to install a perl module, on a local computer, for a quick whois on a few domains. Catching the shell’s output is more convenient in this case.

Instead of first writing and then reading from a file, it makes more sense to use a pipe. Here’s a quick example:


#!/usr/bin/perl
open (WHOIS, "/usr/bin/whois ewayauto.com |");
$i=1;
while (){
print "Line # ".$i." ".$_;
$i++;
}
print "All done!\n";
close WHOIS;

Thanks to netadmintools for this one.

No Comments

Post a Comment

Your email is never shared. Required fields are marked *