Jump to content

Problem With A Ruby Gem


dangmoo

Recommended Posts

I'm new to Ruby, and just installed the 'net-ssh' gem to simply interact with SSH servers, a function which I need.

The gem is properly located in its folder.

 

I was not sure how to 'include' the gem in my RUBY script as instructed using the line: $:.push("/home/dangmoo/ruby/gems"), so I simply pasted it to the beginning.

 

However, when I try to run a script using this gem, things don't work.

 

This is how the script looks like:

#!/usr/bin/ruby

$:.push("/home/dangmoo/ruby/gems")

require 'cgi'

 

cgi = CGI.new

puts cgi.header

puts "<h1>This is a test</h1>"

 

HOST = '1.2.3.4'

USER = 'root'

PASS = 'password'

Net::SSH.start( HOST, USER, :password => PASS ) do|ssh|

result = ssh.exec!('ls')

puts result

end

 

Although the script should simply return the output of the command 'ls' from my Linux SSH - it only output the HTML line 'This is a test' while the SSH part is totally ignored (without an error message).

 

Do you see anything wrong here?

Can you help me fix this?

 

Thanks!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...