开发者

Problems executing Perl scripts from PHP

开发者 https://www.devze.com 2023-01-12 00:53 出处:网络
Trying to figure this out. I am trying to execute a perl script within php, using sh开发者_高级运维ell_exec() like so:

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;
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消