use strict; use warnings; my $cmd = 'd:\clwhois.exe'; my $ip = '192.168.1.1'; my $file = 'd:\temp\output.txt'; open(STDOUT, ">$file") or die "Can't open $file: $!\n"; # redirect STD +OUT to a temp file system ("$cmd $ip") and warn "Can not execute $cmd: $!\n"; close STDOUT; open(FILE, "$file") or die "Can't open $file: $!\n"; while (){ print; } close STDOUT;