Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sun 23 Nov 2014, 17:12
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Line-buffering the output when forewarding to a file
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [3 Posts]  
Author Message
akash_rawal

Joined: 25 Aug 2010
Posts: 232
Location: ISM Dhanbad, Jharkhand, India

PostPosted: Fri 06 Jul 2012, 13:52    Post subject:  Line-buffering the output when forewarding to a file
Subject description: [color=green]command > path/to/file[/color] doesn't flush output after every line
 

There's a line in pupdial:
Code:
wvdial ${WVISP} ${WVPIN} ${WVAPN} ${WVWRLS} &> /tmp/pupdial.log &

/tmp/pupdial.log is updated after every line of output and can be viewed in wvdial connection log.

When I try to achieve a similar thing for the volume monitor, the output is full-buffered i.e. the output is not flushed after every line. Data gets written only when it has written about 1kb. None of the following work like I want.
Code:
pup-volume-monitor &> "$LOG_FILE" #forewards stderr only

Code:
pup-volume-monitor 2>&1 > "$LOG_FILE" #forewards stderr only

Code:
pup-volume-monitor 2>&1 | cat > "$LOG_FILE" #full buffered output

Code:
pup-volume-monitor 2>&1 | grep --line-buffered "" > "$LOG_FILE" #full buffered output


How can I achieve line buffering, please help!
Back to top
View user's profile Send private message 
jemimah


Joined: 26 Aug 2009
Posts: 4309
Location: Tampa, FL

PostPosted: Fri 06 Jul 2012, 14:17    Post subject:  

The only way I know of is to add explicit buffer flushes to the C code with
Code:
fflush(stdout)
.
_________________
http://saluki-linux.com
Back to top
View user's profile Send private message Visit poster's website 
Karl Godt


Joined: 20 Jun 2010
Posts: 3972
Location: Kiel,Germany

PostPosted: Sat 21 Jul 2012, 22:04    Post subject:  

Cannot find any pup-volume-monitor on the forum .

&>FILE should mean stdout and stderr to FILE . Probably the ' &' fork at the very end of the line is needed here.

Some programs still issue output to the console even with &>FILE.
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [3 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0464s ][ Queries: 12 (0.0054s) ][ GZIP on ]