LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-17-2004, 07:20 AM   #1
game_dev
LQ Newbie
 
Registered: Nov 2004
Posts: 3

Rep: Reputation: 0
gtk2-perl progressbar


I'm making an GUI for a program to transfer files over USB to an ogg-player. When it transfers it show's the amount of bytes sent.

Code:
ruben@localhost Projects $ ./test.pl
2731363 sent.
as you see it shows all it's output on one line.
But when pipe the output of the program ( not my gui) to a file (like ifp upload>>foofile) I get all the lines separated:

0 sent
16 sent
43 sent
...

My main problem is to capture the output while the program is still transfering (since it's the only way to make an usefull progressbar )

To get output I normally use

Code:
#!/usr/bin/perl -w
open(PROC,'ifp upload /home/ruben/test.mp3 test.mp3 |') || die;
while(<PROC>){
  print $_;
}
close PROC;
But when I run this I only get the last line == useless

Anybody knows a way to capture my output while the program is transfering ?
 
Old 11-17-2004, 08:02 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
sounds like the string output includes a \r character which will return the carriage without a line feed. if you want it to print sequential rows, use a regex to remove \r, ro alternatively you might want to change the record seperator for that while loop to be \r. i do this exact same thing in acidrip to read mencoders stdout stream. have a look... http://acidrip.sf.net
 
Old 11-17-2004, 09:58 AM   #3
game_dev
LQ Newbie
 
Registered: Nov 2004
Posts: 3

Original Poster
Rep: Reputation: 0
I just added

$/ = "\r";

like in acidrip and it works great
thanx
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
BASH progressbar TheSpork Linux - General 2 10-09-2005 11:15 PM
bootsplash OK but progressbar not working sigeberht Slackware 4 06-27-2004 07:51 AM
where can find out a progressbar like this quietheart Linux - General 1 02-22-2004 07:11 AM
bootsplash progressbar bugyugo Red Hat 0 12-08-2003 07:11 AM
lsdvd - gtk2-perl help please Giallo998 Linux - Newbie 1 11-11-2003 07:13 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration