Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2004

    Unanswered: PHP error running Shell Script

    I have made a file TestCopy.php to try and execute a shell script!
    echo "Hello just to check that I am Here";
    exec (" test.txt test1.txt");
    echo "<br> That was it I wonder what the result is?";
    ?> is as follows:
    cat $1 > $2
    echo "** Transalation succesful ** " >> $2

    I mark my directory as CHMOD 777.
    I have marked TestCopy.php as CHMOD 777
    I have marked as CHMD 777.
    I try to execute the script

    It seems to execute, I can see my echo's being displayed,
    I receieve no error message. But after execution no output file!!!!
    Can anyone please help??

    I am basically trying to pass a file to an executable “”, read a file then write the results back to a new file?

  2. #2
    Join Date
    Nov 2006
    After copying your code (almost, I added end of lines characters "\n" to the end of the echo statements and removed the <br>) and set the permissions (a little bit stricter than yours)

    I tried running your 'exec' line from the command line and got:
    $ test.txt tmp.txt
    bash: command not found
    I also got the same error when running the php:
    $php testcopy.php
    Hello just to check that I am Here
    bash: command not found
    That was it I wonder what the result is?
    I'm not sure why you aren't getting any error messages, but this makes sense to me. As your probably aware, the default path on most (all, except dos/windows, as far as I've seen) shells doesn't include '.'
    So you'll probably need to change the exec line to `./ ...` or put the shell script somewhere that is in your path.

    Apart from that your code works for me. But I would also suggest adding a shebang to the start of your shell script (#!/bin/sh)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts