php can't execute a perl script via exec

I'm trying to execute a perl script from php. That perl script is reading a webpage and producing an xml file with some data. If i exec it via shell everything works as expected but when I'm trying to automate the whole thing via php nothing works.

I've tried this:

exec("perl /absolute/path/to/perl/script/", $output, $result);

when i echo the $result variable it displays 2. I've switched the php safe_mode On and Off several times but nothing changed. Also tried to set the safe_mode_exec_dir without positive results.

When i exec a simple ls

exec("ls", $output, $result);

everything goes well, i get the list of files and $result is 0.

The perl script has chmod 777 so that it would not be a problem of permission. Also his folder has 777.

I'm almost sure that the issue is something about the server but I'm not able to find out what.

Any help would be really appreciated.


-------------Problems Reply------------

You probably need to specify the full path to your perl executable.

Try typing which perl to see what the full path is, then place that full path in your exec call.

Your example seems to be missing the end quote for the first argument. I would also make sure that the executable for perl is in your path. Lastly, not only does the folder need to have the execute bit set, but all of the directories up to root need to be set to allow perl to access the script. It is fairly common for a directory to be 750 such that a group can get in, but not the world. As a user you may be able to cd there and see the script, but you must look at it from the perspective of the users that is executing the script -- presumably the id your webserver is running as.

Category:php Views:2 Time:2011-02-23
Tags: php perl exec

Related post

  • How to execute a perl script within php and capture error messages? 2010-04-21

    I am trying to execute a Perl script like so: /usr/bin/ec2-consistent-snapshot 'vol-dr3131c2' When the Perl script fails it exits using 'die' and prints out an error message. I can see that error message when executing manually, but I am failing to c

  • How do I execute a perl script in java? 2010-10-18

    How do I use java to execute a perl script. Thanks a bunch :) --------------Solutions------------- Without knowing any more of the requirements: Runtime.getRuntime().exec("/path/to/perl /path/to/perl/script"); Documentation about Runtime.exec: http:/

  • How can I execute a Perl script inside C++ console application? 2010-10-23

    I am new to C++ programming :). I was wondering what would be the best and easiest approach for this problem. I have a C++ console application and a Perl script. Both of them are to be integrated. To be more specific need to write perl

  • How to execute a perl script from a PL/SQL script? 2010-12-15

    I have a requirement to execute a perl script from a PL/SQL script. The perl script executes various system commands, and this piece is already developed. The piece I am having trouble with is executing the perl script from the PL/SQL code. Can someo

  • Which has better performance: executing a Perl script from C++ via system call, or calling a DLL file? 2011-02-05

    I am new to C++ coding. I wanted to execute a Perl script (that controls an equipment) inside a C++ Visual Studio Win32 application. I was wondering what would be the most optimized approach in this regards? Call system function and execute that part

  • Want to execute a perl script within a perl script 2011-08-01

    I need a help on perl. I am new to it. I want to execute a perl script from my parent perl script and cover the following scenarios: if (my child script takes more time than my time limit) { I need to kill the child script with a return code logged i

  • Convert Perl Executable to Perl Script 2011-09-15

    Hi All, I have converted the perl script to perl executable using perlcc .So Now I want to convert perl executable to perl script. Is there any way to do this...? --------------Solutions------------- No. I remember compiling my first C program in 199

  • How can I find out what script, program, or shell executed my Perl script? 2011-12-16

    How would I determine what script, program, or shell executed my Perl script? Example: I might want to have human readable output if executed from shell (customized for each type of shell), a different type of output if called as a script from anothe

  • How can I execute a Perl script using the Ant exec task? 2009-08-04

    I currently have this in my Ant build script: <exec dir="${basedir}" executable="perl"> <arg line="${basedir}/ -major"/> </exec> However, when that runs, I get this error message: [exec] Could not open -major [exec] Result

  • Building executable from perl scripts programs using PAR on Activestate Windows 2011-01-17

    I am used to build windows executable programs from perl scripts using Activestate PDK; now I would like to give a try to the PAR way to do the same thing - still using Activestate distribution: > This is perl 5, version 12, subversion 2 (v5.12.2)

  • rails won"t execute a perl script in the same folder as the controller 2011-02-16

    I have a simple method def execperl system("perl") redirect_to :controller => :mycontroller, :action => :index end Where I put this mycontroller (that contains index and execperl) in the same folder as the However, when

  • Executing a Perl script on Java button ActionEvent 2014-07-10

    I'm trying to run a Perl script when I push a button on a JFrame. I read around and realize that I need to use Runtime.exec() to run a command, and this works in the following code: import; public class Charts { public static void

  • Perl Script, Fork/Exec, System claims my process has died when in fact only my child process has died 2009-11-17

    I have a Perl script that does a fork/exec to start another tool in the background and monitor some file system changes while this other tool is running. This seems to work like expected. When I start this Perl script from a shell (e.g. Bash), of cou

  • Executing the perl script in dos with perl invoked makes difference? 2013-11-13

    why is the behaviour so ? contains: #! perl -slw use strict; use Win32::Console::ANSI; use Term::ANSIColor qw(:constants); print BLACK, ON_WHITE, "black on white\n"; print WHITE, ON_BLACK, "white on black\n"; print GREEN, ON_CYAN, BLINK

  • How can I get name of the user executing my Perl script? 2009-09-04

    I have a script that needs to know what username it is run from. When I run it from shell, I can easily use $ENV{"USER"}, which is provided by bash. But apparently - then the same script is run from cron, also via bash - $ENV{"USER"} is not defined.

  • NetBeans fails to execute a Perl script when compiling C++ project 2010-10-06

    I installed NetBeans 6.9.1 with C++ support. I also installed MinGW. When I create a C++ project and run it, I get this: I checked the C++ configuration in NetBeans (looks good): Perl is installed on my PC under C:\perl. I tried reinstalling NetBeans

  • Problems executing Perl scripts from PHP 2010-08-13

    Trying to figure this out. I am trying to execute a perl script within php, using shell_exec() like so: <?php $output=shell_exec("./ > test.txt"); //$output=shell_exec("./"); echo $output; ?> It will not write output to a file us

  • execute perl script as passed argument 2010-12-04

    Im trying to execute a perl script as a passed argument from the command line. I compiled a c file and named it "Test", so trying to pass an argument I try this >Test perl -e "print qq{A\n}x500" which I want to mean, run Test file and pass 500 A's

  • Execute Perl script from C program 2011-03-07

    I currently have a program that I have written in C, and I am interested in integrating into it a fairly lengthy perl script that someone else wrote that accomplishes a similar function but does so in a different way. I am not interested in translati

Copyright (C), All Rights Reserved.

processed in 0.175 (s). 11 q(s)