1

i am trying to execute perl script using php shell_excel function. but instead of printing output it ask to open perl file when i execute php script.

i tried below

$result = shell_exec('app.pl');

app.pl contains below script

#!/usr/local/bin/perl

$count = 0;
while (<stdin>) {
    @w = split;
    $count++;
    for ($i=0; $i<=$#w; $i++) {
    $s[$i] += $w[$i];
    }
}

for ($i=0; $i<=$#w; $i++) {
    print $s[$i]/$count, "\t";
}

print "\n";

print "hi";

any suggestion ?

amit nindroda
  • 65
  • 3
  • 11
  • 1
    why not run all that in php in the first place? –  Feb 04 '18 at 06:26
  • 2
    What do you mean by "it ask to open perl file"? – ikegami Feb 04 '18 at 06:36
  • @ikegami I think it tries to download the file instead of executing it. @amit try running perl and pass the script as an argument: `shell_exec('perl app.pl')` – ob-ivan Feb 04 '18 at 10:57
  • @ob-ivan i tried but still not display anything – amit nindroda Feb 05 '18 at 06:14
  • What is the result of `var_dump($result)`? Have you tried simplifying your perl script to just `print "hi\n"`? Do the files reside in the same folder? Do you get any output if you enable error reporting: https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display ? – ob-ivan Feb 05 '18 at 08:45
  • @ob-ivan yes in the script file i just keep print "hi\n" and i display var_dump($result) it displays NULL as output. – amit nindroda Feb 05 '18 at 10:08

0 Answers0