i'm trying to execute a command on the console from a perl prog and capture the output.
Code:
$cmd = "dir";
open(outF, '>x.txt') || die;
open(STATUS, "$cmd |") || die "can't fork: $!";
while (<STATUS>) {
print <STATUS>;
@cmdoutput = <STATUS>;
print outF @cmdoutput;
}
@cmdoutput = <STATUS>;
print outF @cmdoutput;
close STATUS || die "bad command: $! $?";
close(outF);
I've used perl before on snmp, but that was more of a get stuff working as i go along project. I'm not sure what type <STATUS> is, and I want to get that to a file or unterstand how to use that variable. i've been mucking aaround for a while and it's 5:30 am, so forgive any blatant mistakes
