PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Indeed, that looks like it should work, but you will need to compile it on a similar platform to your server. In other words, find out what GCC version, major kernel version, etc. and make sure you compile it on said system, if not, it may reject the executable, if it will even allow PHP to execute a binary that you upload.
omniuni wrote:Indeed, that looks like it should work, but you will need to compile it on a similar platform to your server. In other words, find out what GCC version, major kernel version, etc. and make sure you compile it on said system, if not, it may reject the executable, if it will even allow PHP to execute a binary that you upload.
Hmm, any suggestions on how to compile the source file on my server? Would I have to install GCC on my server then run a command that compiles the yamdi.c?
omniuni wrote:Indeed, that looks like it should work, but you will need to compile it on a similar platform to your server. In other words, find out what GCC version, major kernel version, etc. and make sure you compile it on said system, if not, it may reject the executable, if it will even allow PHP to execute a binary that you upload.
I tried compiling the source code on my machine and then uploading the executable to my server, and I don't think my server is accepting it.
Hmm, any suggestions on how to compile the source file on my server? Would I have to install GCC on my server then run a command that compiles the yamdi.c maybe?
Especially if this is on a goDaddy server, though, I seriously doubt that they're going to be OK with this.
However, if you get SSH access, you should be able to just remote into the server, WGET the source files, and run the compile commands there. It is unusual, however, for this to be allowed on shared servers.
Just as a side note, did you check the permissions on the executable?
Do you think that where you compile a program has an effect on it's compatibility? I wouldn't have thought that, considering that a C compiler is a program that is not a property of say Microsoft or any biased company.
The compilation is done for whatever the host system is.
If you use gcc on windows, it compiles for windows, and optimized for your specific processor and architecture.
Use gcc on Linux, and the result will be a Linux executable, again, optimized for your kernel version and processor.
Different compilers may have different efficiencies, but the bottom line is that while the C language may not be specific to a company like Microsoft, Windows is. It is the Kernel, not the processor that determines, technically, whether a binary will run.
Since ntoskrnl.exe and Linux are two very different kernels, compiling on a machine with one will not work on the other. You may, however, be lucky enough to get a binary from a linux 2.6.x to run on a different 2.6.x or a binary for WinXP to run on Vista.
This is why there is such a problem with programs that work only on Windows. It's not that the code could not be easily written to be cross-platform, but the companies don't feel like spending the time to compile and support Linux or MacOS versions, and they are certainly not going to give the code to the community so that they could make a native version.
WINE is a compatibility layer that tries to make Windows executables work on *nix systems by translating system calls. It's an interesting process, and WINE is getting better every day. In other words, the WINEserver actually serves as a "pseudo windows kernel" allowing Linux to execute a program that was originally compiled under Windows.
JellyFish wrote:Is there a function in php that allows me to execute a command on the command-line or shell? I remember coming across one but don't remember what the name of it was. I checked on php.net and couldn't find it. Eeek.