문제

I'm trying to write a PHP script to run a fairly simple shell command. The command is Pygmentize, which is a binary I have installed and is located in /usr/local/bin/pygmentize-1.4. This works fine while in the command line of my web server (directory in apache server), but when I tried to include the statement in a PHP script it fails.

$command = "pygmentize -f html $extra_opts -l $language $temp_name";
$output = array();
$retval = -1;

exec( $command, $output, $retval );
echo $retval;

The command returns the value 127, which seems to mean that the script cannot find the binary, and I think I installed to the wrong location. I installed it to a directory located in the same directory as the PHP script, but I'm not sure where to go from there. Any advice would be greatly appreciated!

I guess to summarize, how/where can I install Pygments such that it is accessible to my script?

도움이 되었습니까?

해결책

Use full path, because php runs under another user and ./ is not the apache directory when this user executes the script:

$command = "/usr/local/bin/pygmentize-1.4-f html $extra_opts -l $language $temp_name";
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top