popen(), standard input, output etc. ???


im trying to create pdf files from ps files on the fly and also run some applescripts from php. i can access the command line from php with exec() to run commands, but some commands arent working for me. ive tried:

%exec("rm -rf somefile");

and that worked, but:

%exec("ps2pdf input.ps output.pdf");

isnt working. the similiar commmand from the terminal runs fine. also, im trying to run simple applescripts from php using popen(), but i have a feeling im way off. ive read the doc pages on php.net, but im still not getting it. the terminal command would be as simple as:

% osascript -e "return( 6 + 4)"

with php and popen(), im guessing it would be:

$query = "return(6 + 4)";
$cmd = "osascript";
$fp = popen($cmd, "r");
fwrite($fp, $query);

but thats just not working and the page is locking up.

any ideas?
%exec("ps2pdf input.ps output.pdf");

try to use the full path of the utility, it could be as simple as that.

as for your other command: it might be a ludicrous security hole, something like:

$somefile = "foo.file; rm -Rf /";
%exec("rm -rf $somefile");

can destroy your whole system, or at least your user data

im aware that rm -rf is a security hole, but i wasnt accepting input from users. i meant to say that the exec command was letting me run something like "rm -rf somefile", but im not able to run "ps2pdfwr input.ps output.ps"

i think ive got to look more into piping commands with popen.