# IO.popen and gets

**URL:** <https://www.ruby-forum.com/t/io-popen-and-gets/113485>\
**Category:** Ruby\
**Created:** [August 31, 2007, 4:11pm UTC](https://www.ruby-forum.com/t/io-popen-and-gets/113485 "2007-08-31T16:11:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![unbewusst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/ba9def/32.png) [@unbewusst](https://www.ruby-forum.com/u/unbewusst)\
**Post date:** [August 31, 2007, 4:11pm UTC](https://www.ruby-forum.com/t/io-popen-and-gets/113485/1 "2007-08-31T16:11:56Z")

</div>

in order to get the answer of rsync when doing a backup with ruby, i  
make use of IO.pope like that :

f = IO.popen("#{RSYNC} -a#{verboseStr} #{progressStr} --eahfs  
“#{i.path}” “#{@usbkey.stringValue.to\_s}”", “r”)  
while( r = f.gets ) do  
log( “#{r}” )  
end

it works but not the way i’d like to get.

if i do :  
#{RSYNC} -a#{verboseStr} #{progressStr} --eahfs “#{i.path}”  
“#{@usbkey.stringValue.to\_s}”

on a terminal, i get each line, given by rsync, at a time thru Ruby it  
isn’t exactly the same, i get the whole lines at a time, thought i’d  
prefer one after each other avoiding the user to be bored, because it  
sees something …

may be i’m wrong somewhere with this part :

while( r = f.gets ) do  
log( “#{r}” )  
end

???
