jpleveille Posted June 18, 2009 Share Posted June 18, 2009 Hi phpfreaks, I've been coding with PHP since PHP2.0/fi and a lot has changed since then (~1998?). Anyway, now I'm trying to install PHP on Vista and managed to get Apache 2.2 running along with MySQL 5.1 and support for PHP 5.2.x (can't remember the version I installed). It all works fine for most apps such as PHPMyAdmin and PHPBB. Now I have an issue with executing commands using exec() or system(). I'm trying to create an image conversion batch tool in PHP using some ini files to set my options and send them to the command line tool "convert.exe" from ImageMagick. If I run the commands myself in the command prompts cmd.exe, everything runs fine and I get the result I want, less the automation to convert more than thousand images in a row. If I run the command from a PHP script with something like this: exec($command, $output, $return); I get return code 1, an empty output (I figured it's because the output is sent to stderr instead of stdout) and no image conversion at all. On WinXP, it works just fine. I started looking for help and noticed psexec, a tool from Microsoft labs that allow you to run remote applications from a console and even get a GUI from it. Now, if I replace my command like this: exec("psexec ". $command, $output, $return); It works!!! Or does it? It keeps opening command prompts each time exec() is called (i.e. for each image to convert; pretty annoying). That would be sufficient if I wasn't required to fetch the output from this window... which I can't because it's executed in a sub-window. Using ">" won't work to redirect the output in a temp file, it would redirect the output of psexec instead (which is empty) I looked at psexec options and there's none to allow you to run the remote application/command in the current console (I'm running PHP from command prompt, in CLI, but I also tested it on a web page with the same results). I also tried to use a folder from my Documents And Settings application data folder. I heard that in Vista, applications can only write stuff there (that explains why all my save games in the games I play are stored there; or perhaps it's also because each computer user has its own game profile?). But it doesn't work either. So I'm asking: how can I get convert.exe (from ImageMagick) to work from PHP exec() function on a Vista machine? Link to comment https://forums.phpfreaks.com/topic/162683-vista-exec-and-imagemagick/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.