Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

outputting results to a temporary file

Status
Not open for further replies.

gammaman1

Programmer
Jun 30, 2005
23
US
Hi,

I just installed windows XP on my machine, and I was trying to figure out how to output the results of an execution to a file. For example:

check_execute("grep test testfile");

sub check_execute {

if (system("$_[0]") != 0)
{
print "failed execution";
print ($?>>8);
die "failed execution";
}
}

in unix, i could just use the '>' operator, but i have no idea how to do it in windows.

thanks
 
sorry, i forgot to mention that i want to output the results of "grep test testfile". I installed a windows version of grep.

thanks
 
you won't get any output from system
use backticks ``
Code:
$result=`grep test testfile`;
make sure your path covers the path to grep, and you may need to specify your path to testfile, unless you change directories in perl before calling the backtick call

--paul

cigless ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top