Search code examples
javascriptphpperl

Executing a Perl file from php


I am working with Perl and php, and I would like to call a Perl program at some point.
Both of them are in the same folder and I don't need to pass any argument, just execute it.

I don't know if I need to use JavaScript or just a

exec();

doing something like this:

$result = exec(perl changePass.pl)

I already tried both of them and I wasnt able to execute it.


Solution

  • There is absolutely no need to involve JavaScript.

    The first argument of exec needs to be a string. You can't just shove shell commands into the middle of PHP.

    exec("perl changePass.pl")
    

    Ensure that perl is on your path (this is likely). Ensure that changePass.pl is in the current working directory (this is very likely to not be the case). Alternatively use full paths to them.