how to control stdout buffer??

S

sonet

#!/usr/bin/perl
$|=1;
print "Content-Type: text/plain\r\n\r\n";
print `ldapsearch -b dc=abc,dc=edu -D cn=Manager,dc=abc,dc=edu -w abc -h
ldap.abc.edu -LLL "uid=*"`;

If i do this job in unix comand ,the stdout will continue output.
But if i do this job in cgi,the stdout will pause to output until the
ldapsearch complete.
And this process will cost about 10 mins.
How to control the cgi stdout buffer?
 
A

A. Sinan Unur

#!/usr/bin/perl
$|=1;
print "Content-Type: text/plain\r\n\r\n";
print `ldapsearch -b dc=abc,dc=edu -D cn=Manager,dc=abc,dc=edu -w abc
-h ldap.abc.edu -LLL "uid=*"`;

If i do this job in unix comand ,the stdout will continue output.
But if i do this job in cgi,the stdout will pause to output until the
ldapsearch complete.

The output is not being paused. You have told perl to read all the lines
output by ldapsearch and then print them rather than reading the output
of ldapsearch line by line.
And this process will cost about 10 mins.
How to control the cgi stdout buffer?

I am not sure exactly what you are asking, but, either:

http://www.stonehenge.com/merlyn/LinuxMag/col39.html

or

#! perl

$| = 1;

use strict;
use warnings;

open my $ls, 'ls -l . |'
or die "Cannot open pipe to ls: $!";

while(<$ls>) {
print;
sleep 1;
}

close $ls
or die "Cannot close pipe to ls: $!";

__END__

might help.

See perldoc perlopentut and perldoc perlipc for more information on
pipes. Clearly, you would open a pipe to the command whose output you are
interested in rather than to ls.

Sinan.
 
S

sonet

sorry , my english is poor!

Thanks.
But the method will occur <defunct> in linux,
if the command is not terminate and httpd connection close.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top