librelist archives

« back to archive

net/ssh

net/ssh

From:
Per Mikaelsson
Date:
2011-09-13 @ 07:05
I am trying my hands on shoes but got stuck. I am trying to connect to a
remote computer using ssh and issue a command, got it working in cli but it
is a no go for me to get it working on shoes. This might be a simple thing
but new as I am I can't get past it. Here is what my code looks like atm

Shoes.setup do
gem 'net-ssh'

end
require "rubygems"
require "net/ssh"
Shoes.app do
  button "Connect" do
  append Net::SSH.start( '192.168.100.127', 'fox', :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|
            para success
          if success then
            alert "uploaded"
          else
            alert "Fail"
          end
        end
      end
  end
end
end
end

Re: [shoes] net/ssh

From:
ashbb
Date:
2011-09-13 @ 11:56
Hi Per Mikaelsson,

Thank you for the post and welcome to Shoes ML! :)

> got it working in cli
Ah, umm....
I just tried the following snippet, 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

So, I guess if your code doesn't work with Shoes, that would not be the
cause of Shoes. ;-)
I don't know the usage of net-ssh well. But try out the following. It works
with Shoes 3 for Windows.

Shoes.setup do
  gem 'net-ssh'
end
require 'rubygems'
require 'net/ssh'
Shoes.app do
  button "Connect" do
    Net::SSH.start( 'hostname', 'xxxxx', :password => "xxxxxx" ) do |ssh|
      para ssh.exec! 'ls -la'
    end
  end
end

Hope this helps,
ashbb

Re: [shoes] net/ssh

From:
Per Mikaelsson
Date:
2011-09-13 @ 12:08
Thanks for the fast response. And what can I say it works as a charm, Now I
can build more and get myself into more issues I don't understand :)

Shoes is so cool even I that is 37 going on 38 imagine that I can learn it
;)
Happy shoeing everyone.

2011/9/13 ashbb <ashbbb@gmail.com>

> Hi Per Mikaelsson,
>
> Thank you for the post and welcome to Shoes ML! :)
>
>
> > got it working in cli
> Ah, umm....
> I just tried the following snippet, 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
>
> So, I guess if your code doesn't work with Shoes, that would not be the
> cause of Shoes. ;-)
> I don't know the usage of net-ssh well. But try out the following. It works
> with Shoes 3 for Windows.
>
>
> Shoes.setup do
>   gem 'net-ssh'
> end
> require 'rubygems'
> require 'net/ssh'
> Shoes.app do
>   button "Connect" do
>     Net::SSH.start( 'hostname', 'xxxxx', :password => "xxxxxx" ) do |ssh|
>       para ssh.exec! 'ls -la'
>     end
>   end
> end
>
> Hope this helps,
> ashbb
>

Re: [shoes] net/ssh

From:
ashbb
Date:
2011-09-13 @ 12:15
> Now I can build more
Cool!

> and get myself into more issues I don't understand :)
hahaha.
Please feel free to post and share your findings.

Let's learn and improve Shoes!

ashbb