I am connecting to a server, want to run a command and print the output. Here's the code:
def log_in
Net::SSH.start('hostname', 'username', :password => "password") do |ssh|
ssh.open_channel do |channel|
output = channel.exec "ls" do |ch, success, data|
if success then
alert "Result: #{output} #{success} #{data}"
end
end
end
end
end
The result is "output" being an empty list [], "success" being true and "data" being empty. Obviously, this shouldn't be the case, as when I am logged in through the terminal and hit the "ls" command, there are several files / folders listed. Where's my mistake?
Interestingly enough, if I send gibberish as a command, e.g. instead of "ls", I send "asdfgh", it returns the same ([], true, empty). Using Shoes / Ruby.