Page 1 of 1

Starting an external program from PHP

Posted: Sun Mar 16, 2008 10:40 am
by jasper_c
Hi All,

I have an idea for a website which I'm hoping to eventually retire on (that's the theory anyways :) ). Anyway the idea is that people will be able to edit their word processor documents - Microsoft Word to start with, Spreadsheets - Excel etc from wherever they happen to be. Even if those applications are not installed on their own PCs.

I have quite have a lot of experience programming, having worked on embedded C for AƩrospacial, but am pretty new to PHP.

The idea I had was that I could just install a copy of those applications on MY pc and when the user came to my site, I would just fire them up using PHP so that they could just work away on their stuff across the net.

The problem I am having is that when I use PHP's exec command to launch Word, it only seems to run locally. I.E NOTHING appears on the webpage at all. Just a blank screen.

I know it's probably something simple, but does anyone have any pointers as to what I'm doing wrong.

Thanks

Re: Starting an external program from PHP

Posted: Sun Mar 16, 2008 11:06 am
by bertfour
I know it's probably something simple, but does anyone have any pointers as to what I'm doing wrong.
Yes its simple. You just have to port the MS apps to php. Otherwise, good idea :D

Re: Starting an external program from PHP

Posted: Sun Mar 16, 2008 11:21 am
by Verminox
PHP's program control functions (such as exec() and shell_exec()) will call the process on the host machine, and give you the output, similar to a command line interface, but instead of a terminal, you get the output in a PHP string. You can then display this output on your screen using echo.

When using PHP for a website, you can only deliver data via the HTTP protocol, which means you can deliver stuff like plain text or HTML. You cannot expect Microsoft Word to open interactively in the viewer's browser. If you want to emulate Word in the browser, you will have to do so using either HTML/Javascript or maybe a Java applet, using the data returned by functions such as exec() or shell_exec(). However, I dont know if products like Microsoft Word even have command line alternatives (and I don't expect them too), so you will probably have to first write your own native program (or do the whole thing in PHP itself) that can parse and process .doc or .xls documents and then make your own GUI using HTML/Javascript or a Java applet.

*I've not used the program control functions much so if there could be something I am not aware of, please wait for somebody else to confirm it.