PHP external program call

General Tech Bugs & Fixes 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

My setup is as follows: Windows 7, XAMPP with Apache and PHP enabled I have a PHP script in which I call an f="https://forum.tuteehub.com/tag/external">external program to do run a conversion. This f="https://forum.tuteehub.com/tag/external">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 f="https://forum.tuteehub.com/tag/fine">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.

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.