Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > platform independent piped input stream from system call

Reply
Thread Tools

platform independent piped input stream from system call

 
 
Danny Challis
Guest
Posts: n/a
 
      12-29-2010
Hi all,
I want to get an input stream from a system command in this manner:

f = open("|ls")
while( [not end of output] )
f.gets
end

but I would like it to be platform independent. The output of the
command I'll be using is massive (hundreds of GB) so I cannot load to
memory or write to a temp file. Is there a good platform-independent way
to do this?

Thanks!

Danny.

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Jeremy Bopp
Guest
Posts: n/a
 
      12-29-2010
On 12/29/2010 12:10 PM, Danny Challis wrote:
> Hi all,
> I want to get an input stream from a system command in this manner:
>
> f = open("|ls")
> while( [not end of output] )
> f.gets
> end
>
> but I would like it to be platform independent. The output of the
> command I'll be using is massive (hundreds of GB) so I cannot load to
> memory or write to a temp file. Is there a good platform-independent way
> to do this?


Check out IO.popen:

http://rdoc.info/stdlib/core/1.9.2/IO.popen

-Jeremy

 
Reply With Quote
 
 
 
 
Danny Challis
Guest
Posts: n/a
 
      12-29-2010
That is exactly what I was looking for! Thank you for pointing me in
the right direction!

Jeremy Bopp wrote in post #971324:
> On 12/29/2010 12:10 PM, Danny Challis wrote:
>> memory or write to a temp file. Is there a good platform-independent way
>> to do this?

>
> Check out IO.popen:
>
> http://rdoc.info/stdlib/core/1.9.2/IO.popen
>
> -Jeremy


--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Kaspar Schiess
Guest
Posts: n/a
 
      12-30-2010
Danny Challis wrote:
> That is exactly what I was looking for! Thank you for pointing me in
> the right direction!
>


And if that was good, this might be even better:
https://github.com/ahoward/open4

k


 
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
Creating a piped stream and reading from it ??? surfunbear@yahoo.com Perl Misc 4 10-31-2005 02:11 AM
Invoking 'diff' from java with piped input David Kensche Java 11 12-10-2004 03:00 PM
ANN: SCons.0.96 adds Fortran 90/95 support, better Qt support,platform-independent file system actions, improved debugging, lots more Steven Knight Python 0 08-18-2004 03:57 PM
reading piped input in Windows Patrick Useldinger Python 4 11-16-2003 02:19 AM
Piped stream help. Andrew Tucker Java 3 10-06-2003 07:39 PM



Advertisments