I have a Ruby file called "test.rb", and I uploaded it to the server via Net::SCP.
The contents of the file are:
puts "Hello, World"
How do I go about executing that file via Net::SSH and grab the STDOUT or STDERR?
This is the error I'm getting:
Bash: Ruby not found
That's because Net::SSH won't load a login shell.
I've tried everything from Net::SSH::Shell to SSHkit and rye to solve the problem of executing the script and getting any STDOUT back.
How do I execute a script via Net::SSH when I don't have access to a login shell, and get any STDOUT or STDERR?
I'm using Ruby-2.1.0.
command = "ruby -e'print :hello'"
Net::SSH.start(server_connection.host, server_connection.ssh_username, port: server_connection.ssh_port, paranoid: false) do |ssh|
job.stdout = ""
job.stderr = ""
ssh.exec! command do |channel, stream, data|
job.stdout << data if stream == :stdout
job.stderr << data if stream == :stderr
end
ssh.close
end
rubyorRuby? try/full/path/to/ruby