Running a Unix Command-Line App via PHP?
am 18.09.2007 10:25:40 von Vik Rubenfeld
I'm developing a web site in PHP for an Apache server.
I have a particular stand-alone application that takes a text file as
input, and produces a text-file as output. It's usually run from the
Unix command line. I'd like my PHP code to provide the input text file,
run the stand-alone application, and then read the output text file and
reformat it for display on the site.
Is there a way for my PHP app, to cause this Unix command-line
application to run?
Thanks in advance to all for any info.
Re: Running a Unix Command-Line App via PHP?
am 18.09.2007 10:40:25 von Lars Eighner
In our last episode,
, the lovely
and talented Vik Rubenfeld broadcast on comp.lang.php:
> I'm developing a web site in PHP for an Apache server.
> I have a particular stand-alone application that takes a text file as
> input, and produces a text-file as output. It's usually run from the
> Unix command line. I'd like my PHP code to provide the input text file,
> run the stand-alone application, and then read the output text file and
> reformat it for display on the site.
> Is there a way for my PHP app, to cause this Unix command-line
> application to run?
> Thanks in advance to all for any info.
see the system() function in the manual. If your application can write to
STDOUT instead of writing to an output file, you can use the backtick
operator (see execution operators in chapter 15).
--
Lars Eighner
Countdown: 490 days to go.
What do you do when you're debranded?
Re: Running a Unix Command-Line App via PHP?
am 18.09.2007 11:52:20 von panda31
On 18 sep, 10:25, Vik Rubenfeld wrote:
> I'm developing a web site in PHP for an Apache server.
>
> I have a particular stand-alone application that takes a text file as
> input, and produces a text-file as output. It's usually run from the
> Unix command line. I'd like my PHP code to provide the input text file,
> run the stand-alone application, and then read the output text file and
> reformat it for display on the site.
>
> Is there a way for my PHP app, to cause this Unix command-line
> application to run?
>
> Thanks in advance to all for any info.
Hi,
I suppose you work with a LAMP configuration so, to execute on your O/
S an application, you must use system() or exec() functions.
Take care about input! If you use directly data from user input, think
about escaping them.
More information: http://fr.php.net/manual/en/function.system.php
Ciao