1

My setup is as follows: Windows 7, XAMPP with Apache and PHP enabled I have a PHP script in which I call an external program to do run a conversion. This external program is an EXE file, which requires 3 attributes:

  • The source file
  • The destination file
  • Additional flags (conversion type etc)

When I use the command line tool built into XAMPP to execute my script, everything works fine. But when I use the exec() function in my PHP script, no output file is created. I'm pretty sure the conversion is actually happening (it takes about 5 seconds, about the same time it takes to run the PHP script).

I think it's a permissions thing, so I already moved the EXE file to the same folder as my PHP file and adjusted the permissions of the entire folder (I granted all permissions to all users). I also disabled the Windows UAC and tried to put the command in a BAT file. The file just is not created.

Any help or tips would be greatly appreciated!

EDIT: My PHP code is as follows:

exec('c:\converter.exe c:\src.txt c:\dst.txt -f', $output);
print_r($output);

When I print out $output, the array turns out to be empty. When I put the exact same command in Command Prompt, the code works like a charm (no syntax errors). I use absolute paths as well.

3
  • how you are using the exec() function?
    – stderr
    Commented Jul 12, 2013 at 13:47
  • Use the 'echo' command whilst using the exec to see what is happening, then post back the results and your php code. e.g. > echo exec("ipconfig);
    – Ash King
    Commented Jul 12, 2013 at 13:48
  • exec('converter.exe inputfile outputfile -f HT') Commented Jul 12, 2013 at 13:53

1 Answer 1

1

Thank you very much for your input! As it turns out, it was Windows issue caused by the 'Interactive Services Detection' feature. Apache was running as a system service, which prevented calls to external programs (with a GUI). I disabled the run-as-service feature in XAMPP, which solved the problem. A more thorough explanation can be found here: http://php.net/manual/en/book.exec.php

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .