Click here to Skip to main content
15,894,291 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When one writes an executable to be executed by php exec command what extension must it have for Windows and for Linux OS.
Posted
Updated 1-Dec-15 2:28am
v3

It must have an extension that is known by the system as executable and must be of course also an executable. So if you can execute it from the command line (Windows console or Linux shell), it can be also executed by the exec() function.

The usual extensions for compiled programs are .exe with Windows and none with Linux. Linux will check the file to be executable (file permission) and if it is an executable. So it may have any extension but using none is common (and preferred) because extensions may be associated with special tasks.

If it is not a compiled program but a shell script it is .bat or .cmd with Windows and usually .sh with Linux.

With other script types use the corresponding extension (e.g. .php, .pl for Perl) and ensure that the operating system knows how to handle these (it will then start the corresponding script interpreter passing the script file name).
 
Share this answer
 
At the (possibly very) end, the PHP exec command invokes the shell to execute the passed command, hence, anything could be considered an executable by the shell is executed (e.g. shell script, batch files on Windows, etc..). Please note, on Linux, executables have not a special extension (they have the 'executable' file attribute).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900