473,799 Members | 2,665 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Include() with cgi problems

VB
Dear friends,

I have a big problem. With an usersonline script I need to extract in
php the output of a cgi using buffering output in this way:

<?php
ob_start();
include('/home/mysite/public_html/cgi-bin/usersonline/online.cgi');
$contents = ob_get_contents ();
ob_end_clean();
echo $contents;
?>

In this way the code of the cgi is displayed, not executed. Why? I need
to execute and catch the output in this way...with
include('http://www.mysite.com/cgi-bin/usersonline/online.cgi') works
well but the requestes come with the same ip (my server) and this is
not the results which I want.

Thanks,

Vincenzo, Rome, IT

Nov 5 '05 #1
1 1753
VB (vi************ ****@gmail.com) wrote:
: Dear friends,

: I have a big problem. With an usersonline script I need to extract in
: php the output of a cgi using buffering output in this way:

: <?php
: ob_start();
: include('/home/mysite/public_html/cgi-bin/usersonline/online.cgi');
: In this way the code of the cgi is displayed, not executed. Why? I need
: to execute and catch the output in this way...with
: include('http://www.mysite.com/cgi-bin/usersonline/online.cgi') works
: well but the requestes come with the same ip (my server) and this is
: not the results which I want.

You are including a file, so PHP reads the data into memory, and runs it
as a php program (i.e. it looks for <?php ...?> tags and runs any php code
it finds.)

That is, in fact, identical to what happens using the "http://server..."
syntax, except that the include gets the data from a different location.
Instead of reading the data from a file handle, it reads the data from a
socket handle. The socket is being sent the data from a web server.

In both situations the include will check for <?php tags and maybe run the
data as a php script.

In neither situation does the include ever run the file as a cgi script.

HOWEVER, since it's a local file, you can run it yourself using php
functions such as

exec() system() passthru() escapeshellcmd( ) pcntl_exec()
system() backtick operator

Look them up to check which would be best for you.

THE ENVIRONMENT

Because it is a cgi script it will expect certain environment variables to
be set. But since php is already running in a cgi environment then you
might not need to set any of the variables yourself - they are already
set. Whether they have the correct values for the script will depend on
what the script does. I would just give it a try and see what happens.

--

This programmer available for rent.
Nov 5 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

43
5131
by: steve | last post by:
I am quite frustrated with php’s include, as I have spent a ton of time on it already... anyone can tell me why it was designed like this (or something I don’t get)? The path in include is relative NOT to the immediate script that is including it, but is relative to the top-level calling script. In practice, this means that you have to constantly worry and adjust paths in includes, based on the startup scripts that call these...
13
2599
by: Bryan Harrington | last post by:
Hello all.. I'm working on an application that I'd like to use some shared files. Right now my directory structure is: / (root) .../Shared/ .../Reports/ .../Tools/
22
38562
by: Weston C | last post by:
I know of course that you can use <script src=""></script> in an HTML document to include javascript code you don't want to spill all over the page. I'm wondering if there's a way to include other pieces of javascript code from *within* javascript.... a la #include in C, @import in Java, use/require in Perl, include()/require() in PHP, etc.... Thanks, Weston
28
3892
by: Ramesh | last post by:
Hi, I am currently maintaining a legacy code with a very very large code base. I am facing problems with C/C++ files having a lot of un-necessary #includes. On an average every C/C++ file has around 150+ .h files included. I find 75% of the files unnecessary and could be removed. Considering the fact that I have a huge code base, I can't manually fix it. Are there any tools that would report un wanted .h files?
8
6178
by: Jacob | last post by:
Is there still a difference on the two forms of includes: #include "some/file" and #include <some/file> I always use the latter and see no rational
1
1072
by: www.espiredreams.net | last post by:
I recently started using vs2003 from vc++ 6.0. I am having the starngest of problems. I cannot include any files into my code (string.h or iostream.h). I installed vs '03 after a clean install of windows (no problems with prior versions of vs). I have checked to make sure all the include directories are correct. It just doesn't make sense to me. ANY help would be well appreciated.
4
2250
by: John Smith | last post by:
I have a project that consists of about a dozen translation units. I use a command line compiler and it occured to me that I could simplify compiling the project by #include(ing) them in a header that looks something like this: /* project.h */ #include "aaa.c" #include "bbb.c" #include "ccc.c" ....
2
1934
by: William van Zwanenberg | last post by:
Hi there, I wonder if you guys can help. I'm currently experiencing some coding problems what with trying to use PHP and javascript in tandem. What I'm ultimately trying to achieve is use Javascript to access the DOM objects of any given page within the web site I'm building to dyanamically resize any and all text elements. I have Javascript some code that works
1
3483
by: Zbigniew | last post by:
Hi, Compiler: GCC 3.3.5 OS: SuSE Linux (Kernel: 2.6.11) I reorganized my source code and now almost all my header files went to "Include" folder. Now when compiling with -I option I have plenty of problems with system include files: "conflict with previous declaration"
3
2639
by: =?Utf-8?B?VG9kZCBEb2JtZXllcg==?= | last post by:
I am working on developing a program using Visual Studio 2003 but am having problems getting my program to find my GL.h and GLU.h, and I am guessing it will have the same problems trying to link to the .lib and .dll files. What do I all need to do to get this to properly compile and link. Here is what I have done so far. Inside my main project directory, I added a folder called "OpenGL" and inside this folder are 3 sub-folders,...
0
10495
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10269
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10248
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5597
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4148
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2942
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.