Command line funciton

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!

Moderator: General Moderators

User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Re: Command line funciton

Post by JellyFish »

omniuni wrote:This is a windows program and will not work under your Linux server, unless you configure it with WINE somehow.

I'm sorry,

-OmniUni
I figured that would be the case.

Does anyone know of a linux version of a FLVMDI? I'll do some googling.

Thanks guys.
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: Command line funciton

Post by omniuni »

http://rubyforge.org/projects/flvtool2/

but you will need a server that supports ruby.
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Re: Command line funciton

Post by JellyFish »

I'll check into that one as well, but I've also found:

http://yamdi.sourceforge.net/

This looks like it would work? It says on the site:
yamdi should run under *BSD, Linux and Win32 (tested with FreeBSD, MacOSX, Ubuntu and Windows XP)...
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: Command line funciton

Post by omniuni »

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.
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Re: Command line funciton

Post by JellyFish »

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?
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Re: Command line funciton

Post by JellyFish »

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?
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: Command line funciton

Post by omniuni »

You'll likely have to get SSH access.

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?
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Re: Command line funciton

Post by JellyFish »

Permissions on the file are 755.

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.
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: Command line funciton

Post by omniuni »

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.
padduweb
Forum Newbie
Posts: 7
Joined: Mon Jul 21, 2008 2:27 am

Re: Command line funciton

Post by padduweb »

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.

Is there such a thing or am I mistaken?
Yes Check this site for answer
http://php-answers.blogspot.com/2008/07 ... mmand.html
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: Command line funciton

Post by omniuni »

Note that as per the rest of this thread, the method of execution is not the problem, but the OS compatibility.
Post Reply