mm, bit basic maybe but its got me stumped 🙁

trying to call a Perl script that should return some text by using:

$output = shell_exec("./cgi/function 98");
echo "output form shell_exec ";
echo $output;

where 98 is a variable. Basically nothing gets written to $output but running the function from a terminal does produce some output. I've tried moving the page calling the function in to the cgi bin and setting shell_exec("function 98"); but that doesnt work either. Is my addressing of the funciton wrong?

TIA

    i don't think that will work as shell_exec only executes and doesn't get content.

    try using virtual.

    virtual('./file.cgi');
    

      Using virtual returns a output of '1' (not what im expecting)?

      From php.net/shell_exec:
      shell_exec -- Execute command via shell and return complete output as string

      Would of thought this is the function i'm after but im a newbie so could easily be wrong....

        ok, so then i could be wrong about the output. I've never used shell_exec in this manner, usually use it to execute scripts.

        you probably need to include the function file into the script which has the shell exec call.

          Sorry if this sounds obvious but have you tried running the script from the terminal? What output do you get? Also, are there any other effects of the script other than it's output which you could check to see if the script has actually run?
          HTH
          Rob

            Originally posted by seby


            you probably need to include the function file into the script which has the shell exec call.

            Sorry, don't think i understand this, could u explain it? Many thanks 🙂

              Soreted now. It was a bug in the script that was tring to detect whether it was being called from a terminal or not. thanks 4 the help, and i ended up using SHELL_EXEC.

                Write a Reply...