# Lsdvd and Ruby

**URL:** <https://www.ruby-forum.com/t/lsdvd-and-ruby/184261>\
**Category:** Ruby\
**Created:** [February 27, 2010, 2:51pm UTC](https://www.ruby-forum.com/t/lsdvd-and-ruby/184261 "2010-02-27T14:51:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![davedave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a6a055/32.png) [@davedave](https://www.ruby-forum.com/u/davedave)\
**Post date:** [February 27, 2010, 2:51pm UTC](https://www.ruby-forum.com/t/lsdvd-and-ruby/184261/1 "2010-02-27T14:51:04Z")

</div>

Hello

lsdvd rather handily offers to output the chapter structure of a DVD as  
a Ruby hash.

lsdvd -Or -c -t1 (output as ruby hash, chapters, track 1)

Thing is, I don’t understand how I can use this in a Ruby script. I’ve  
previously issued Unix commands with system(name of command) and I can  
do this with the above as well, but I don’t see where, or how I get that  
Ruby hash and something I can use elsewhere in the script. system()  
seems to issue the command, not store the output.

Please note, if you haven’t already guessed, I’m kinda new to Ruby.  
Thanks for any help can be offered.

jp

---

<div class="post-metadata">

**Author:** ![davedave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a6a055/32.png) [@davedave](https://www.ruby-forum.com/u/davedave)\
**Post date:** [February 27, 2010, 3:02pm UTC](https://www.ruby-forum.com/t/lsdvd-and-ruby/184261/2 "2010-02-27T15:02:16Z")

</div>

John-Paul Harold wrote:

> Hello
> 
> lsdvd rather handily offers to output the chapter structure of a DVD as  
> a Ruby hash.
> 
> lsdvd -Or -c -t1 (output as ruby hash, chapters, track 1)
> 
> Thing is, I don’t understand how I can use this in a Ruby script. I’ve  
> previously issued Unix commands with system(name of command) and I can  
> do this with the above as well, but I don’t see where, or how I get that  
> Ruby hash and something I can use elsewhere in the script. system()  
> seems to issue the command, not store the output.
> 
> Please note, if you haven’t already guessed, I’m kinda new to Ruby.  
> Thanks for any help can be offered.
> 
> jp

Use backqoutes for your command:  
output = `yourcommand`

To access the error stream as well, you should have a look at open3:  
[http://www.ruby-doc.org/stdlib/libdoc/open3/rdoc/index.html](http://www.ruby-doc.org/stdlib/libdoc/open3/rdoc/index.html)

Marvin
