Mohammad
Mohammad

Reputation: 1929

save the exec output into a file

I'm running a shell command ( its a web scraper ) via php exec ( although, i have tried system and passthru as well) and i need to save the results in a file, (preferably .txt),The output data is some HTML. it creates the file, but its always empty.

please help me out.

Below is the code, im trying to run

file_put_contents('data.php',passthru('casperjs the_file_in_which_i_run.js',$output));

also tried

file_put_contents('data.php',exec('casperjs the_file_in_which_i_run.js',$output));

and

file_put_contents('data.php',system('casperjs the_file_in_which_i_run.js',$output));

Upvotes: 5

Views: 7960

Answers (1)

Marc B
Marc B

Reputation: 360602

exec(...., $output);
file_put_contents('file.txt', $output);

Upvotes: 9

Related Questions