Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling perl script from php

Status
Not open for further replies.

proggybilly

Programmer
Apr 30, 2008
110
US
Hi all,
I am having a slight issue, I have run a perl script before from php but for the life of me cannot get it to work again.

I have tried many methods using system() exec() shell_exec() passthru() but cannot for the life of me get any of them to work.

When I call up my php page, the script does not run.

Example of my call:
Code:
 $args = "me you message name.txt";
 $result = exec("scripts/myscript.pl $args");

Please, any help?
 
permissions? is the path accurate?
consider using this instead
Code:
passthru("scripts/myscript.pl $args");

or set the return parameter of exec()
 
I have tried exec, passthru, system, shell_exec, and backticks.. Nothing seems to work.. All files are owned by root, and the myscript.pl is chmod 777.
 
I have even copied myscript.pl to the same location as my php page to try that and it doesn't work. Getting aggrevated I am.
 
there should be some output. what do you get?

whilst debugging also turn error_reporting up high and make sure that errors are being displayed.
 
You may need to tell it what interpreter to use.

shell_exec("/usr/bin/perl /path/to/myscript.pl $args");
 
Does your perl script use an -s switch,

Code:
#!/usr/bin/perl -s

Chris
 
I have turned on error reporting as high as I can figure to make it (E_ALL & E_STRICT).

I have tried shell_exec("/usr/bin/perl /path/to/myscript.pl $args"); with no luck.

No, there is not a -s switch.

I get no out put what so ever, even the logfile that should be created when the script is run is not being created.
 
Good news! I got it working. Seems there was a misplaced } in my perl script.

Now if I can just get a return value and have it not display on the screen.
 
Code:
shell_exec("/usr/bin/perl /path/to/myscript.pl $args", $return);
the return value will be in $return
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top