Trying to figure this out. I am trying to execute a perl script within php, using sh开发者_高级运维ell_exec() like so:
<?php
$output=shell_exec("./tst.pl > test.txt");
//$output=shell_exec("./tst.pl");
echo $output;
?>
It will not write output to a file using ">" filename.txt. It will work if I execute without directing it to a filename as I can confirm this with echo.
Does this have to do with using ">"? Permissions should be fine as I am able to run the same perl script on command line and direct to file. Any suggestions for executing this?
The output of "test.txt" will be used as input:
<?php
$data = array();
$InputFile = file("test.txt");
...
?>
It was definitely a permissions problem. Wrote the file out to /tmp and it worked fine.
<?php
$output=shell_exec("./tst.pl > /tmp/test.txt");
echo $output;
?>
精彩评论