Ruby for dummies - Nine Steps for NetBeans and Net::SSH
-----------
Hello World
-----------
The system cannot find the path specified
total 32
drwx------ 2 root root 16384 Mar 28 2008 lost+found
drwxrwx--- 3 oracle oracle 4096 May 8 02:29 oracle
drwxr-xr-x 7 test test 4096 Mar 28 2008 test
-------------
Goodbye World
-------------
Above is the final product after some frustration with JRuby and Netbeans detailed in previous postings. I've been trying to follow simple Ruby SSH tutorials with little or no luck.
The primary cause is due to net/ssh and Ruby's reliance on the PuTTY pageant service when running in Windows, explained --> here (the dl/import issue).
For me, the message "The system cannot find the path specified" threw a flag that things were not working when in fact they actually were.
So in lieu of my efforts and time spent, I'm writing a tutorial for a JRuby beginner trying to obtain the same results.
- Install Netbeans 6.5 (6.1 should work also)
- If its not already install the two required NetBeans plugins: "Ruby and Rails" and "JRuby and Rails" through the plugins interface.
- Install the two required JRuby "gems": net-ssh (>2.0.4) and jruby-openssl (>0.3)
- Create a new JRuby Application through
File --> New Project --> Ruby --> Ruby Application - Overwrite
C:\Program Files\NetBeans 6.5 Beta\ruby2\jruby-1.1.3\lib\ruby\gems\1.8\gems\net-ssh-2.0.4\lib\net\ssh\authentication\pageant.rb
with this version: --> pageant.rb - Overwrite
C:\Program Files\NetBeans 6.5 Beta\ruby2\jruby-1.1.3\lib\ruby\gems\1.8\gems\net-ssh-2.0.4\lib\net\ssh\known_hosts.rb
with this version: --> known_hosts.rb - Copy/Paste the following code:
require 'rubygems'
require 'net/ssh'
puts "-----------"
puts "Hello World"
puts "-----------"
Net::SSH.start('192.168.1.7', 'test', :password => "passw0rd") do |ssh|
# capture all stderr and stdout output from a remote process
#output = ssh.exec!("talia")
# capture only stdout matching a particular pattern
stdout = ""
ssh.exec!("ls -l /home") do |channel, stream, data|
stdout << stream ="="> - Modify "main.rb" code in NetBeans so that it points to a device on your networking running ssh.
- Run your program
- Hopefully you had success!? :)
Comments
http://github.com/angelic/net-ssh/commit/dd4adaa368583dbeb6cb10038b6961a50354e5c6
Angel N. Sciortino
-Tres
"This small change of mine in net-ssh works on my machine. Can you let me know if it works for you too?
http://github.com/angelic/net-ssh/commit/dd4adaa368583dbeb6cb10038b6961a50354e5c6
-Angel"