Running a Unix Command-Line App via PHP?

This is a discussion on Running a Unix Command-Line App via PHP? within the PHP Language forums, part of the PHP Programming Forums category; I'm developing a web site in PHP for an Apache server. I have a particular stand-alone application that ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-18-2007
Vik Rubenfeld
 
Posts: n/a
Default Running a Unix Command-Line App via 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.
Reply With Quote
  #2 (permalink)  
Old 09-18-2007
Lars Eighner
 
Posts: n/a
Default Re: Running a Unix Command-Line App via PHP?

In our last episode,
<vikr-1ED27C.01253918092007@earthlink.vsrv-sjc.supernews.net>, 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 <http://larseighner.com/> <http://myspace.com/larseighner>
Countdown: 490 days to go.
What do you do when you're debranded?
Reply With Quote
  #3 (permalink)  
Old 09-18-2007
panda31
 
Posts: n/a
Default Re: Running a Unix Command-Line App via PHP?

On 18 sep, 10:25, Vik Rubenfeld <v...@mindspring.com.invalid> 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

Reply With Quote
  #4 (permalink)  
Old 09-19-2007
Vik Rubenfeld
 
Posts: n/a
Default Re: Running a Unix Command-Line App via PHP?

Thanks very much, guys. That worked great.
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 09:26 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0