Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How to make STDOUT unbuffered, please guide me

Reply
Thread Tools

How to make STDOUT unbuffered, please guide me

 
 
sahana H V
Guest
Posts: n/a
 
      07-09-2009
Hi,

Can i make stdout associated with my own file handle as unbuffered ?
If so can you please tell me how to do it?

What i am trying to do is:

open (HVS, "/<command> <cmnd_args> 2>&1 |"); <==
at this point of time i need stdout to be unbuffered .so that command output
should be logged to HVS in unbuffered fashion.

Thanks,
-Sahana


 
Reply With Quote
 
 
 
 
david
Guest
Posts: n/a
 
      07-09-2009
On Jul 9, 4:57*pm, "sahana H V" <(E-Mail Removed)> wrote:
> Hi,
>
> Can i make stdout associated with my own file handle as unbuffered ?
> If so can you please tell me how to do it?
>
> What i am trying *to do is:
>
> open (HVS, "/<command> <cmnd_args> 2>&1 |"); * <==
> at this point of time i need stdout to be unbuffered .so that command output
> should be logged to HVS in unbuffered fashion.
>
> Thanks,
> *-Sahana


perldoc -q unbuffer
 
Reply With Quote
 
 
 
 
Josef Moellers
Guest
Posts: n/a
 
      07-09-2009
sahana H V wrote:
> Hi,
>
> Can i make stdout associated with my own file handle as unbuffered ?
> If so can you please tell me how to do it?
>
> What i am trying to do is:
>
> open (HVS, "/<command> <cmnd_args> 2>&1 |"); <==
> at this point of time i need stdout to be unbuffered .so that command output
> should be logged to HVS in unbuffered fashion.


You can't, unless you have control over the command.

It's the binary of the command (more precise: the stdio library linked
to the command) which does the buffering and if stdout is not connected
to a terminal (and a pipe is *not* a terminal), it will buffer its output.

Josef
--
These are my personal views and not those of Fujitsu Technology Solutions!
Josef Möllers (Pinguinpfleger bei FTS)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://de.ts.fujitsu.com/imprint.html
 
Reply With Quote
 
Josef Moellers
Guest
Posts: n/a
 
      07-10-2009
Ben Morrow wrote:
> Quoth Josef Moellers <(E-Mail Removed)>:
>> sahana H V wrote:
>>> Can i make stdout associated with my own file handle as unbuffered ?
>>> If so can you please tell me how to do it?
>>>
>>> What i am trying to do is:
>>>
>>> open (HVS, "/<command> <cmnd_args> 2>&1 |"); <==
>>> at this point of time i need stdout to be unbuffered .so that command output
>>> should be logged to HVS in unbuffered fashion.

>> You can't, unless you have control over the command.
>>
>> It's the binary of the command (more precise: the stdio library linked
>> to the command) which does the buffering and if stdout is not connected
>> to a terminal (and a pipe is *not* a terminal), it will buffer its output.

>
> You could try using IO::Run's ">pty>" syntax, or using a pty yourself.


Maybe Expect is an option if the OP needs to parse the command's output.

Josef
--
These are my personal views and not those of Fujitsu Technology Solutions!
Josef Möllers (Pinguinpfleger bei FTS)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://de.ts.fujitsu.com/imprint.html
 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
beginner Q: Kernel#puts, STDOUT, $stdout relation Andreas S Ruby 3 12-09-2006 12:39 AM
Problems redirecting STDOUT (NOT sys.stdout) to a pipe. Elad Python 0 03-19-2006 01:30 PM
copy stdout fails with permission denied when stdout is redirected brian.mabry.edwards@gmail.com Perl Misc 2 12-07-2005 10:49 PM
please help... ...me learn C++ please please please :) KK C++ 2 10-14-2003 02:08 PM



Advertisments