Linux Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOperating SystemsLinux Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 24th, 2001, 09:43 AM
JeffCT JeffCT is offline
Dev
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jan 2001
Posts: 1,436 JeffCT User rank is Sergeant Major (2000 - 5000 Reputation Level)JeffCT User rank is Sergeant Major (2000 - 5000 Reputation Level)JeffCT User rank is Sergeant Major (2000 - 5000 Reputation Level)JeffCT User rank is Sergeant Major (2000 - 5000 Reputation Level)JeffCT User rank is Sergeant Major (2000 - 5000 Reputation Level)JeffCT User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 5 h 52 m 59 sec
Reputation Power: 40
xterm buffers program output?

Whenever I run a program through an xterm it seems to buffer all of the output (to stdout) until the program is finished. I thought this was just a PHP thing but I wrote similar scripts in C and Perl and they do the same.

Scripts:

PHP
PHP Code:
for($i=0;$i<10;$i++)
{
      echo 
"Hi...\n";
      
flush();
      
sleep(2);



Perl
Code:
for($i=0;$i<10;$i++)
{
     print "Hi...\n";
     sleep(2);
}


C
Code:
#include <stdio.h>

void main()
{
     int i;

     for(i=0;i<10;i++)
     {
          printf("Hi...\n");
          sleep(2);
     }
}


They all do the same thing... I get

Hi...Hi...Hi...Hi...Hi...Hi...Hi...Hi...Hi...Hi...

after 20 seconds.

Maybe I'm just stupid but I could swear I never had this problem when writing QBasic and C programs for DOS years ago...

I have also tried things like this:

./program.php | more
./program.php > output

But the output is still buffered until the end...

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsLinux Help > xterm buffers program output?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap