3

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
Michael Kohl
  • 66,324
  • 14
  • 138
  • 158
Fox
  • 31
  • 1

1 Answers1

0

Your code is trying to receive data first which is not the case usually. Remove the on_data:

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.exec "ls -la" do |ch, success|
          para success
          if success then
            alert "uploaded"
          else
            alert "Fail"
          end
        end
      end
    end
  end
end
phil pirozhkov
  • 4,740
  • 2
  • 33
  • 40