Output aint there until code executed!(?)

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Ace
New php-forum User
New php-forum User
Posts: 9
Joined: Sun Oct 27, 2002 7:28 am

Output aint there until code executed!(?)

Postby Ace » Tue Feb 04, 2003 1:02 am

Hey,

Ok, Im working on some script that is using the exec function. Why I mention this only? Well, Im almost 100% surtain that this is the "bad-guy" here! My problem is that when I run the script, it does all the job FIRST and THEN show me the output I do in the script! Even echo("BLABLA"); on first row (after the <?php) doesnt help! Even tried flush(), but no luck! This is really getting to bugg me, because I dont get why the h-ll it wont show anything, until all is done!

Also, I can mention that I run my script using the cli version. However, using the "normal" one (cgi?) dosnt matter, since I got the same problem there aswell - No output until all is done!
Oh, and also, the script run programs like unzip etc (not that it should make any difference!, since I got output here and there, so output should be now and then, BEFORE some exec functions are called!)

ANY ideas on how to solve this would be nice,
Thanks,
Ace

User avatar
Redcircle
Moderator
Moderator
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA
Contact:

Postby Redcircle » Tue Feb 04, 2003 10:32 pm

you want to get the output from the exec() ?

Ace
New php-forum User
New php-forum User
Posts: 9
Joined: Sun Oct 27, 2002 7:28 am

Postby Ace » Tue Feb 04, 2003 11:55 pm

No. I want the output to come while the script is executing. And I know that exec aint showing the output (thats the point of it) But, say I got for instance:

echo "Script Started...";
exec($SCRIPTROOT . "unzip -d $file");
echo "Script Ended.";

Ofcource in this example it goes kinda fast, so, not that noticeable, but in my example where the script does more, NOTHING is outputed to the screen (the echo statements) until the script is DONE! Now, WHY is this? I want it to print the echo thingies while script runs damnit!

The script works fine else, but its quite annoying to have a FLOOD of output when the script is done... I wanna see the progress while runing!

Ace

Ace
New php-forum User
New php-forum User
Posts: 9
Joined: Sun Oct 27, 2002 7:28 am

Some code to try

Postby Ace » Sat Feb 08, 2003 2:16 am

Wierd! I thought, If I shorten the code until it works, I find what code that is making the problem...

I came to this:

<?php

echo("-* Process start *-\n");
sleep(2);
echo("-* Process end *-\n");

?>

--------------------------------------------------------------------------------


Here, nothing is shown until time is up by the sleep()

Ideas what can be the problem? What am I missing?
Ace

Ace
New php-forum User
New php-forum User
Posts: 9
Joined: Sun Oct 27, 2002 7:28 am

Problem solved

Postby Ace » Sun Feb 09, 2003 2:49 am

The "bad guy" was output_buffering = 4096!! I changed that to
output_buffering = Off and it works as I wanted!!

Wierd.. Anyone wanna explain this? I mean, why the hell this is on by default???

Ace


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 1 guest