Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
    
how you are using the exec() function? –  QMechanic73 Jul 12 '13 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 Jul 12 '13 at 13:48
    
exec('converter.exe inputfile outputfile -f HT') –  Flock Dawson Jul 12 '13 at 13:53

1 Answer 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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.