views:

31

answers:

1

Trying to figure this out. I am trying to execute a perl script within php, using shell_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");
...
?>
A: 

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