CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
passing parameters from php to perl

 



daryl552007
Novice

Jul 23, 2009, 1:43 PM

Post #1 of 20 (1367 views)
passing parameters from php to perl Can't Post

Hi guys,

I dont know if I should ask this here, but I have this PHP script and I want it to run a perl program I have. I am using exec but I cant seem to run the program thru php.

Here is my code:

exec("perl /home/daryl/test/test_send.pl");

Hope you guys can help me with this.


shawnhcorey
Enthusiast


Jul 23, 2009, 3:53 PM

Post #2 of 20 (1363 views)
Re: [daryl552007] passing parameters from php to perl [In reply to] Can't Post


In Reply To
exec("perl /home/daryl/test/test_send.pl");


Is perl in your $PATH?

Try:

Code
exec("/usr/bin/perl /home/daryl/test/test_send.pl");


__END__

I love Perl; it's the only language where you can bless your thingy.

Perl documentation is available at perldoc.perl.org. The list of standard modules and pragmatics is available in perlmodlib.

Get Markup Help. Please note the markup tag of "code".


daryl552007
Novice

Jul 23, 2009, 4:16 PM

Post #3 of 20 (1361 views)
Re: [shawnhcorey] passing parameters from php to perl [In reply to] Can't Post

I did this already but the script still doesnt run. What else could be wrong?


shawnhcorey
Enthusiast


Jul 23, 2009, 4:22 PM

Post #4 of 20 (1360 views)
Re: [daryl552007] passing parameters from php to perl [In reply to] Can't Post


In Reply To
I did this already but the script still doesnt run. What else could be wrong?


Have you looked in the server logs? For Apache they're at /var/log/apache2/

__END__

I love Perl; it's the only language where you can bless your thingy.

Perl documentation is available at perldoc.perl.org. The list of standard modules and pragmatics is available in perlmodlib.

Get Markup Help. Please note the markup tag of "code".


daryl552007
Novice

Jul 23, 2009, 4:25 PM

Post #5 of 20 (1359 views)
Re: [shawnhcorey] passing parameters from php to perl [In reply to] Can't Post

how do I access this?


johnpc831
Novice

Jul 23, 2009, 4:38 PM

Post #6 of 20 (1357 views)
Re: [daryl552007] passing parameters from php to perl [In reply to] Can't Post

Review the apache log as shawn mentioned, ensure that your perl executuble is actually /usr/bin/perl using 'which perl', and lastly, make sure your Perl script is readable to apache.

You may have to review your apache configuration to find out where the logs are being stored because that varies by system. You might find that in httpd.conf.


shawnhcorey
Enthusiast


Jul 23, 2009, 4:58 PM

Post #7 of 20 (1353 views)
Re: [johnpc831] passing parameters from php to perl [In reply to] Can't Post


In Reply To
Review the apache log as shawn mentioned, ensure that your perl executuble is actually /usr/bin/perl using 'which perl', and lastly, make sure your Perl script is readable to apache.

You may have to review your apache configuration to find out where the logs are being stored because that varies by system. You might find that in httpd.conf.


Actually, the configuration files for Apache2 are in /etc/apache2/ Most of what once was in in httpd.conf is now in apache2.conf Other parts have been broken out into the various files that populate the directory.

The Apache error log, /var/log/apache2/error.log can be read with a text editor.

__END__

I love Perl; it's the only language where you can bless your thingy.

Perl documentation is available at perldoc.perl.org. The list of standard modules and pragmatics is available in perlmodlib.

Get Markup Help. Please note the markup tag of "code".


ichi
User

Jul 23, 2009, 6:18 PM

Post #8 of 20 (1349 views)
Re: [daryl552007] passing parameters from php to perl [In reply to] Can't Post


In Reply To
Hi guys,

I dont know if I should ask this here, but I have this PHP script and I want it to run a perl program I have. I am using exec but I cant seem to run the program thru php.

Here is my code:

exec("perl /home/daryl/test/test_send.pl");

Hope you guys can help me with this.


you should make sure the one running your webserver has permissions using perl and has permissions to go into /home/daryl.


daryl552007
Novice

Jul 26, 2009, 7:04 PM

Post #9 of 20 (1333 views)
Re: [ichi] passing parameters from php to perl [In reply to] Can't Post

I tried running my code in the command line and it works perfectly. The perl and php files are in the same directory too.

here is my code in php

shell_exec("perl autosend2.pl $type $city $message");

and here is what I type in the command line:

perl autosend2.pl $type $city $message


FishMonger
Veteran / Moderator

Jul 26, 2009, 8:28 PM

Post #10 of 20 (1332 views)
Re: [shawnhcorey] passing parameters from php to perl [In reply to] Can't Post


In Reply To

In Reply To
Actually, the configuration files for Apache2 are in /etc/apache2/ Most of what once was in in httpd.conf is now in apache2.conf Other parts have been broken out into the various files that populate the directory.


That depends on how apache was installed and on what platform. On my Wk2 box I have Apache 2.2 installed in 'C:\Program Files\Apache Software Foundation\Apache2.2' and I dont have an apache2.conf file, but my httpd.conf is in 'C:\Program Files\Apache Software Foundation\Apache2.2\conf\'. On my Fedora box I have apache 2.0 and no apache2.conf, but httpd.conf is in '/etc/httpd/conf/'. My error log files are in 'C:\Program Files\Apache Software Foundation\Apache2.2\logs\error_log' or '/var/log/httpd/error_log', depending, of course on which system I'm using.


(This post was edited by FishMonger on Jul 26, 2009, 8:29 PM)


daryl552007
Novice

Jul 26, 2009, 8:33 PM

Post #11 of 20 (1329 views)
Re: [FishMonger] passing parameters from php to perl [In reply to] Can't Post

I am able to run a perl program thru PHP, but when i pass parameters to it thats when there are problems.


FishMonger
Veteran / Moderator

Jul 26, 2009, 8:55 PM

Post #12 of 20 (1328 views)
Re: [daryl552007] passing parameters from php to perl [In reply to] Can't Post

You need to provide more details.

Exactly what problems are you experiencing?

Exactly how are you calling the perl script?

What error message(s) are you receiving?

Can you post a more complete sample of your code?


daryl552007
Novice

Jul 26, 2009, 9:22 PM

Post #13 of 20 (1324 views)
Re: [FishMonger] passing parameters from php to perl [In reply to] Can't Post

What I want to do is pass run a perl script using php as well as pass parameters to it.

What I use to call the perl script in my php page is:

shell_exec("perl autosend2.pl '$type' '$city' '$message'");

but it doesn't give me anything. It doesnt run the script. When I type the same command in the commandline, the script runs fine.


FishMonger
Veteran / Moderator

Jul 27, 2009, 7:07 AM

Post #14 of 20 (1319 views)
Re: [daryl552007] passing parameters from php to perl [In reply to] Can't Post

If the php function isn't executing the perl script, then you might want to ask about that on a php forum. Once you get php to execute the script, we can help with thr perl portion of the problem.


daryl552007
Novice

Jul 27, 2009, 8:03 PM

Post #15 of 20 (1314 views)
Re: [FishMonger] passing parameters from php to perl [In reply to] Can't Post

The php function works fine because I am able to run another perl script through it. But when I call this script I want to run nothing happens, and the funny thing is when I run it in the command line it works perfectly.


FishMonger
Veteran / Moderator

Jul 28, 2009, 5:20 AM

Post #16 of 20 (1310 views)
Re: [daryl552007] passing parameters from php to perl [In reply to] Can't Post

How do you know that the script isn't being executed as opposed to executing but failing is some way and not producing any output?

Can you post the Perl script so we can see what it does?


FishMonger
Veteran / Moderator

Jul 28, 2009, 5:27 AM

Post #17 of 20 (1309 views)
Re: [daryl552007] passing parameters from php to perl [In reply to] Can't Post


In Reply To
What I use to call the perl script in my php page is:

shell_exec("perl autosend2.pl '$type' '$city' '$message'");


Shouldn't that be:

Code
$output = shell_exec("perl autosend2.pl '$type' '$city' '$message'");


Or, if your system is configured correctly, it would be:

Code
$output = shell_exec("autosend2.pl '$type' '$city' '$message'");



FishMonger
Veteran / Moderator

Jul 28, 2009, 5:37 AM

Post #18 of 20 (1307 views)
Re: [daryl552007] passing parameters from php to perl [In reply to] Can't Post

Have you tried redirecting STDERR to SDTOUT?


Code
$output = shell_exec("perl autosend2.pl $type $city $message 2>&1");



daryl552007
Novice

Jul 28, 2009, 7:33 PM

Post #19 of 20 (1304 views)
Re: [FishMonger] passing parameters from php to perl [In reply to] Can't Post

I am able to say that the program didn't run because when I run it in the command line it generates an output but if i call it through php it doesn't give me anything.

What the program does is to pass parameters from the form of my php page and pass the form values to my perl script. the perl script then sends me an email.


KevinR
Veteran


Jul 28, 2009, 8:20 PM

Post #20 of 20 (1303 views)
Re: [daryl552007] passing parameters from php to perl [In reply to] Can't Post


In Reply To
I am able to run a perl program thru PHP, but when i pass parameters to it thats when there are problems.


You should be asking on a PHP forum, because that is where the problem is, not with perl.
-------------------------------------------------

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives