I have an exe file that I'm calling through php using the 'system' command. The exe file then makes calls to Microsoft mapi for some reason that i don't know the mapi is not getting initialized when i call the exe through php but if i run the exe from command line it works fine. Any clue why?
p.s I m running iis on 2008 server
This likely has to do with permissions. PHP will run under whatever user account IIS is configured for that resource.
Also, make sure your paths are correct. If you haven't already, start by explicitly defining the path.
Related
I'm trying to add a remote PHP interpreter to PHPStorm to allow xdebug debugging. When adding an interpreter I'm able to set up the SSH creds properly and connect to the server. However, when I set my PHP executable PHPStorm is not then able to access that executable for some reason, returning PHP Version: Not installed.
Here's what my screen looks like:
And here you can see that when I navigate to the correct directory the php binary is actually there.
I have tried choosing other php binaries on this server and none of them work.
Any help?
Edit:
I've included a picture of what the permissions look like for the php dir in question:
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!
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.
Try to copy your executable file in same folder as your application.
try
exec("script.exe src.txt dst.txt", &$output);
echo $output;
also, do not forget to use escapeshellcmd() to add some security to your application.
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
I have a web accessible PHP script that is using a shell command to drop PDFs to text. I installed Poppler, and am using pdftotext, via MacPorts. I am able to run the command successfully from the CL, and when supplying the full path within the PHP script to '/opt/local/bin/pdftotext'. So, I know that my $PATH is correct and the permissions are sufficient, yet I am still getting an exit status of 127: Command Not Found, when attempting to do simply 'pdftotext' in the exec().
I have tried the answers from How do I add paths to the Apache PATH variable? and http://lists.apple.com/archives/macos-x-server/2008/Sep/msg00433.html. I modified both the /etc/paths and /etc/profile, and added /etc/paths.d/macports all pointing to '/opt/local/bin'. setenv, apache_setenv, etc all had no effect also.
I am using a MAMP (1.9 I think) install for my local development, OSX 10.6, PHP 5.3.5, all a little behind I know :-) ... my $PATH is modified to point to the MAMP bin/php
/etc/paths.d/macports will influence on PATH variable for macports, not for the Apache. You probably need to add /etc/parhs.d/apache (or else) to do what you need.
Edit: also check this and this threads for solutions. It is somewhat outdated but still can help.
I'm trying to call the nbtstat command from PHP using shell_exec(). Apparently that doesn't work because I'm using a 64-bit system.
echo shell_exec("nbtstat");
I've done some research and it seems that the problem is caused by the fact that Windows 64-bit defaults to \Windows\SysWOW64 as System32 folder. But nbtstat is located in the normal \Windows\System32 folder.
In normal applications you can call Wow64DisableWow64FsRedirection to disable this redirection, but I haven't managed to find this in PHP yet.
Is there a way to actually call these commands from PHP within a 64-bit Operating System?
Add "\Windows\Sysnative" to the end of your environment path.
What you need to do is to grant the IUSR_<machinename> user Read & Execute / Read permissions not on the C:\WINDOWS\SysWOW64\nbtstat.exe file, but instead on the C:\WINDOWS\SYSTEM32\nbtstat.exe file.
I have a PHP script I execute in the background from an exec call. Everything works except for the MySQL functions (they don't exist). If I call the script directly from the browser it works fine. What's happening here? Any ideas?
Thank you for your time
Either your command line php was not compiled with php, or php.ini for your command line php does not have the mysql driver module loaded. You'll need to reconfigure and/or rebuild your php installation.
Probably, php_mysql.so is not enabled in your main php.ini but is enabled in an additional ini file added to Apache with PHPIniDir.
Compare output of phpinfo() called from the command line and from a web script. You should see the difference between the ini files and directories used.