Hướng dẫn php exec not working
I want to run an exe file on my server and return the output to the browser screen. The exe file takes a input file and then returns data on the screen. Show Why is this code not working?
It displays "NULL" on the browser screen. I have also tried exec(). There it returns "Array()". hakre 187k48 gold badges418 silver badges801 bronze badges asked Jul 10, 2009 at 4:00 One of the comments on the
It may be disabled if PHP is in safe mode.
You can check your server's PHP settings with the answered Jul 10, 2009 at 4:02 John KugelmanJohn Kugelman 336k66 gold badges509 silver badges559 bronze badges 1 this should work: $output = array(); exec('myprogram < INP.DAT', $output); var_dump($output); answered Jul 10, 2009 at 4:06 tabertaber 3,1463 gold badges44 silver badges70 bronze badges 1 Is myprogram available from a
default shell? Is it in a specific directory? answered Jun 11, 2010 at 5:49 r00fusr00fus 2,4642 gold badges16 silver badges16 bronze badges Sometimes these functions are disabled without the php are in safemode, you have to enable them in php.ini answered Mar 27, 2013 at 1:05 TeodorosTeodoros 3793 silver badges12 bronze badges Not the answer you're looking for? Browse other questions tagged php shell exec or ask your own question.(PHP 4, PHP 5, PHP 7, PHP 8) exec — Execute an external program Descriptionexec(string
Parameterscommand The command that will be executed. output If the result_code If the Return ValuesThe last line from the result of the command. If you need to execute a command and have all the data from the command passed directly back without any interference, use the passthru() function. Returns To get the output of the executed command, be sure to set and use the ExamplesExample #1 An exec() example
The above example will output something similar to: Returned with status 0 and output: Array ( [0] => cmb ) NotesWarning When allowing user-supplied data to be passed to this function, use escapeshellarg() or escapeshellcmd() to ensure that users cannot trick the system into executing arbitrary commands.
See Also
Arno van den Brink ¶ 13 years ago
dell_petter at hotmail dot com ¶ 13 years ago
__construct($cl=false){ Simon ¶ 7 years ago
krjdev at gmail dot com ¶ 10 months ago
msheakoski @t yahoo [email protected] com ¶ 18 years ago
ivk ¶ 1 year ago
Farhad Malekpour ¶ 15 years ago
Paul Sommer ¶ 6 years ago
Bob-PHP at HamsterRepublic dot com ¶ 16 years ago
hans at internit dot NO_SPAM dot com ¶ 20 years ago
layton at layton dot tk ¶ 17 years ago
elwiz at 3e dot pl ¶ 12 years ago
(); juan at laluca dot com ¶ 11 years ago
php dot reg at kjpetrie dot co dot uk ¶ 17 days ago
alvaro at demogracia dot com ¶ 11 years ago
Hypolite Petovan ¶ 2 years ago
Martin Lakes ¶ 11 years ago
bahri at bahri dot info ¶ 13 years ago
$pid === false )
dr_jones153 at hotmail dot com ¶ 14 years ago
|