?
Solved

Executing PHP from Perl - source code is displaying

Posted on 2004-08-19
6
Medium Priority
?
280 Views
Last Modified: 2008-03-17
Hi,

Here's what is happening:

I have a php script which runs fine from the command line, and via the web.  I'd like to call the script from a perl cgi, to get the results (it's ugly, but would be a simple solution to our problem) of it.  

What happens is very strange.  At the point where the php script is supposed to execute, basically, the entire contents of the script are printed out (the script didn't execute) and the perl script seems to bomb out as well.  So on the web page, i see the entire source code to the php script, and also some code from the perl script.  It's really bizarre.

Any ideas on what is causing this?  I'm fairly experienced at perl, cgi, etc., and have tried many tricks to see what might work.  

-Jim
0
Comment
Question by:jimr390
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 48

Expert Comment

by:hernst42
ID: 11846201
can you give an example how your are calling the php-script from perl ??
The following gives me the output of the execute php-script not the source-code

perl -e 'print `php /php/version.php`'
0
 

Author Comment

by:jimr390
ID: 11846772

Ok, the script runs fine from the command line as you show (perl -e 'print `php /php/version.php`')

The problem is running it through the browser as a cgi, then the php callout (using `` or open, doesn't matter) shows source code.

0
 
LVL 48

Accepted Solution

by:
hernst42 earned 600 total points
ID: 11849270
The followoing perl-script works for me (don't know if you need to include all those modules):

#!/usr/bin/perl
use CGI::Carp qw(carpout fatalsToBrowser);
use cgiadapt;
use security;

print qq~Content-Type: text/html

~;

print `/usr/bin/php /php/version.php`;

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 10

Expert Comment

by:eeBlueShadow
ID: 11852725
If you are using open in perl, then you are simply opening the php file (for example like you would in a text editor) and all you will get is the contents.

if you use the command
    print `php /php/version.php`
in your CGI page that should work as you expect
0
 

Author Comment

by:jimr390
ID: 11853341
Well, actually, I was doing an open with a |, which should execute the code and give me stdout.

Anyway, as it turns out, we are abandoning our approach and taking a different tact.  So, the point is moot.

I'll close this out and divide up the points to those who responded - thanks for trying to help.

-Jim
0
 
LVL 48

Expert Comment

by:hernst42
ID: 11853568
you may give us the example how you are doing the exec within perl, so we can see what the problem may be with your code.
0

Featured Post

WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question