Exec and Redirecting Output

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • btysgtmajor@gmail.com

    #1

    Exec and Redirecting Output

    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!

  • Jerry Stuckle

    #2
    Re: Exec and Redirecting Output

    btysgtmajor@gma il.com wrote:
    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!
    >
    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.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    Working...