Iam trying my hands on ruby green shoes but what can I say Iam stuck.
Iam trying as you can see to execute a remote command on a linux box but
the programs hangs when I press the “connect” button… Now I now I am
new to this so don’t look down on me for making some stupid error.
Shoes.app do
button “Connect” do
Net::SSH.start( ‘192.168.100.127’, ‘xxxxx’, :password => “xxxxxx” )
do
|ssh_connection|
ssh_connection.open_channel do |channel|
channel.on_data do |ch, data|
puts data
channel.exec “ls -la” do |ch, success|
if success then
alert “Done”
puts “succsess”
else
alert “Fail”
end
end
end
end
end
end
end
I just tried the following (without Green Shoes), but it didn’t work
well
(got no response).
require ‘rubygems’
require ‘net/ssh’
Net::SSH.start( ‘hostname’, ‘xxxxx’, :password => “xxxxxx” ) do |ssh|
ssh.open_channel do |channel|
channel.on_data do |ch, data|
puts data
channel.exec “ls -la” do |ch, success|
if success then
puts “succsess”
else
puts “Fail”
end
end
end
end
end
If you want to do just only “ls -la” and get back the outputs.
Try out the following. It worked at least on my Windows 7.
require ‘rubygems’
require ‘net/ssh’
require ‘green_shoes’
Shoes.app do
button “Connect” do
Net::SSH.start( ‘hostname’, ‘xxxxx’, :password => “xxxxxx” ) do
|ssh|
append{para ssh.exec! ‘ls -la’}
end
end
end
Regards,
ashbb
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.