php exec() not woking
Posted by: bibhu (14.139.198.---)
Date: April 09, 2015 12:25PM

I am using wamp on a windows machine and just wanted to invoke an exe on this via a php web page. When I am launching the php from commandline on server its working fine but when invoke same php via browser from other machine it does not work and waits forever. My php file is like this

<?php
exec("calc.exe"winking smiley;
?>
When I access this from client (http://localhost/exec.php) it waits forever. I know its a permission issue with apache on windows, but not sure how to fix this.

Options: ReplyQuote
Re: php exec() not woking
Posted by: RiggsFolly (---.as43234.net)
Date: April 09, 2015 06:35PM

your code will execute 'calc.exe' on the server and not on the client machine where you are running the web page. So I imagine calc.exe is sitting there waiting for someone to play with it.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: php exec() not woking
Posted by: bibhu (14.139.198.---)
Date: April 09, 2015 09:31PM

hey actually am using wamp server to run simple command (matlab code code.m file to run) by using exec

php matlab.php

is working perfectly through the cmd terminal it gives the required output but

when am accessing it through local server it was not able to generate any output and doesn't show any error
actually am accessing via

[localhost]

how can i run through the browser show that exec() work

is ther any env path i have to set for wamp show that it can run the command

please help am stuck in it for so long.

Options: ReplyQuote
Re: php exec() not woking
Posted by: Otomatic (Moderator)
Date: April 10, 2015 09:16AM

Hi,

[php.net]

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: php exec() not woking
Posted by: bibhu (---.204.93.111-tataidc.co.in)
Date: April 10, 2015 11:22AM

hey i didn't get the right answer can you please enlighten me how to solve the problem

Options: ReplyQuote
Re: php exec() not woking
Posted by: RiggsFolly (---.as43234.net)
Date: April 10, 2015 11:57AM

Call exec() with all the parameters and check for errors.

And by the way this is not a PHP coder assistance site its just for those that cannot get wampserver itself running.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: php exec() not woking
Posted by: Otomatic (Moderator)
Date: April 10, 2015 03:15PM

Hi,

It seems that you want to use "exec()" as an application launcher. Sorry, but that's not how it works.
All PHP functions able to run an executable file:
- exec()
- passthru()
- shell_exec()
- system()
do not have this executable in a window as would be done with Windows and double-click.
You MUST use the implementing return parameters and test their content.
Example:
$command = 'start /b /wait httpd.exe -v | find "built"';
$output = exec($command, $result);
if(strpos($output, "32-bit" ) !== false)
	$Apache = "32 bit version";
elseif(strpos($output, "64-bit" ) !== false)
	$Apache = "64 bit version";
or
$command = 'start /b /wait httpd.exe  -t -D DUMP_VHOSTS';
ob_start();
passthru($command);
$output = ob_get_contents();
ob_end_clean();
if(!empty($output)) {
 ... Processing command output
}
And if I put a link to the OFFICIAL documentation of the exec() function, it is for you to read it. This, a priori, you did not do, or you would understand why you want to do WILL NOT WORK.
And by the way this forum is not a PHP coder assistance site.



Edited 2 time(s). Last edit at 04/10/2015 04:05PM by Otomatic.

Options: ReplyQuote
Re: php exec() not woking
Posted by: bibhu (14.139.198.---)
Date: April 10, 2015 05:57PM

hey I don't want php solution my php code is working fine.

I can run php matlab.php

it successfully run the code and able to use exec()
able to create matlab output and give output
also all cmd command are working

but when am trying to access through the

localhost/matlab.php

i does not execute exec()
none of the cmd command are working

i want to know how to configure or is there any way to solve this

Options: ReplyQuote
Re: php exec() not woking
Posted by: Otomatic (Moderator)
Date: April 10, 2015 06:09PM

Hi,

> but when am trying to access through the
> localhost/matlab.php
> i does not execute exec()
Use VirtulaHost: WAMPServer 2.5 Homepage the Your Projects Menu and Virtual Hosts

See errors or warnings in log files (wamp\logs\php_error.log). It is the first thing to do when code does not work.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: php exec() not woking
Posted by: bibhu (---.204.93.111-tataidc.co.in)
Date: April 13, 2015 01:33PM

[13-Apr-2015 11:28:02 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'c:/wamp/bin/php/php5.5.12/ext/php_intl.dll' - The specified module could not be found.

its the error am getting in the log files

Options: ReplyQuote
Re: php exec() not woking
Posted by: RiggsFolly (---.as43234.net)
Date: April 13, 2015 02:50PM

This can be cleared by doing this using the wampmanager menus

wampmanager -> Apache -> Version -> 2.4.9 (Click on the version number, yours maybe different)

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote


Sorry, only registered users may post in this forum.