# Getting data from Expect

**URL:** <https://www.ruby-forum.com/t/getting-data-from-expect/111904>\
**Category:** Ruby\
**Created:** [August 13, 2007, 8:16am UTC](https://www.ruby-forum.com/t/getting-data-from-expect/111904 "2007-08-13T08:16:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [August 13, 2007, 8:16am UTC](https://www.ruby-forum.com/t/getting-data-from-expect/111904/1 "2007-08-13T08:16:09Z")

</div>

Hi All,

Can anyone tell me how I can get all the data produced by the command  
“less”:  
PTY.spawn(“cd some\_directory”) do |reader, writer, pid|  
…  
wireter.puts “less some\_text\_file”  
# How do I get the content of the whole file?

Also, what is the command to find whether a ruby script has  
successfully ssh-ed to a machine:  
PTY.spawn(“ssh user@machine”) do |reader, writer, pid|  
# How to find out that the login is successful?

I would really really appreciate your help!

Thanks,  
Greg
