473,394 Members | 1,229 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

passthru + auto generated headers

Hello,

I'm slightly confused with the passthru() command. The program I call writes
html headers itself. However, passthru() makes apache sending some generated
headers first. There's no fault with spaches in the code etc, I think.
Here's an simplified example:
$ cat /www/example.php
<?
passthru("cat /tmp/output");
?>
$ cat /tmp/output
Content-Type: text/html

<HTML><HEAD></HEAD>Message</BODY></HTML>
$ curl -i "http://localhost/example.php"
HTTP/1.1 200 OK
Date: Sat, 16 Jul 2005 14:47:29 GMT
Server: Apache/2.0.54 (Unix) mod_ssl/2.0.54 OpenSSL/0.9.7d DAV/2 PHP/5.1.0b3
X-Powered-By: PHP/5.1.0b3
Content-Length: 66
Content-Type: text/html

Content-Type: text/html

<HTML><HEAD></HEAD>Message</BODY></HTML>
Php5 is compiled as module. Same result with php4.3.10 as cgi.
Thanks for any help! Martin
Jul 17 '05 #1
2 2811
Martin Kofahl <no@spam> wrote:
I'm slightly confused with the passthru() command. The program I call writes
html headers itself. However, passthru() makes apache sending some generated
headers first. There's no fault with spaches in the code etc, I think.
Here's an simplified example:
$ cat /www/example.php
<?
passthru("cat /tmp/output");
?>


http://nl3.php.net/passthru
"passthru -- Execute an external program and display raw output"

In PHP's context output is http body, http headers can be set with
headers.

Couple of possibilities:
-tell/make the program not to output it's own headers
-call the program directly as a cgi
-suppress php's header generation
-have php filter the output and extract the headers

The last one might be most approriate:
just read the output (popen/fopen) line line by line. Everything till
the first blank line are headers, so output them using header().
Everything after that is the body and could be sent to the client with
echo.

Jul 17 '05 #2
Hi Daniel,
I got it using the following codesnip.

unset($output);
$pipe = popen("/usr/local/bin/mapserv", "r");
while(!feof($pipe) and !($output === "\n")) {
$output = fgetss($pipe);

if (!($output === "\n"))
header($output);
}
fpassthru($pipe);
pclose($pipe);

Thank you!
Martin
Jul 17 '05 #3

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

Similar topics

2
by: Kevin Thorpe | last post by:
I have a problem with IE and generated images (jpgraph). It displays them fine but it's not printing them. They appear as little red crosses in print preview. I've fiddled with the cache control...
0
by: Yemi | last post by:
Hi There. I seem to be getting some inconsistent results when using passthru() in safe mode. They appear to be related to the fact that passthru should treat all command arguments as one single...
3
by: Jerry | last post by:
I've found a problem with exec, passthru, shell_exec & system. I'm trying to run the following exec("sort -r -n -k2,2 r1.txt > r2.txt") with r1.txt being a numeric file. The file looks like...
2
by: Greg Chapman | last post by:
I am at my wit's end trying to get information out of Streamline.net's support dept about my problem. They reply quickly enough, but seem to try and give out the least possible amount of info each...
0
by: Steve Barker | last post by:
Hi guys! In Visual Studio .NET, I like to enable auto-generation of XML documentation on the project properties screen, by adding an XML file name under "Configuration Properties" --> "Build"...
3
by: Adel | last post by:
Hello. Is the statement below proved by the ANSI C standard? "It is undesirable to use explicitly sized variables in functions as auto variables or parameters. The values will always be stored as...
6
by: Alpha | last post by:
I retrieve a table with only 2 columns. One is a auto-generated primary key column and the 2nd is a string. When I add a new row to the dataset to be updated back to the database. What should I...
0
by: Viorel | last post by:
Working as a beginner with data objects in Visual Studio 2003 and C#, I use the "Generate Dataset" command in order to generate automatically the dataset objects based on data adapters. Generated...
3
by: Heiko Milke | last post by:
When working with Visual Studio 2003 it sometimes happens that auto-generated code gets lost. I have an .aspx page with its parental c# codebehind page. When creating a webform using the studio...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.