Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Executing PHP from Perl - source code is displaying

Posted on 2004-08-19
6
Medium Priority
?
282 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

610 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