Exec and Redirecting Output

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi all,

 I've searched high and low on this group and elsewhere and can't
really seem to find an answer to this question.  I'm running PHP4 on a
Debian box with Apache.  I'm trying to run the "exec" command
withsomething fairly simple like "cat", e.g. exec("cat < a.txt >
b.txt");.  I'm noticing that no matter what kind of
redirecting/piping/whatever you want to call it I do, the redirections
don't work (at least the redirecting of the output).  I can run the
same command from the command line and it works (of course).

Is this some kind of permissions deal?  I've tried making the call to
be in places where a.txt and b.txt are in a directory that have R/W/X
permissions for PHP (I chose a directory that I actually can
successfully use the fopen et al commands with, including writing).

Does anyone have any ideas?

Thanks in advance!

Re: Exec and Redirecting Output

btysgtmajor@gmail.com wrote:
Quoted text here. Click to load it

Redirection is done by the shell, not the OS.  If you want to use  
redirection you either need to invoke your program through the shell or  
handle the redirection yourself (much easier in C/C++ than PHP, although  
still not easy).

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Site Timeline