B
Bob Smyph
I am trying to connect to one of our UNIX servers. I can connect and can
validate myself but I cant seem to figure out how to 'cd' to another
directory besides my '/home' directory and then execute commands from
the new directory.
below is what I have so far and each time I execute this I receive the
below error
-----ERROR------
C:/ruby/test/SSHtest.rb:75: undefined method `shell' for
#<Net::SSH::Connection::Session:0x2e5bf30> (NoMethodError)
from c:/ruby/lib/ruby/site_ruby/1.8/net/ssh.rb:189:in `start'
from C:/ruby/test/SSHtest.rb:72
-----CODE-----
Net::SSH.start( "hostname", "username", assword => "Password" ) do
|session|
shell = session.shell.open
# script what we want to do
shell.pwd
shell.cd "/"
shell.pwd
shell.test "-e foo"
shell.cd "/file/trying/to/cd/to"
shell.send_data "program\n"
shell.pwd
shell.exit
# give the above commands sufficient time to terminate
sleep 0.5
# display the output
$stdout.print shell.stdout while shell.stdout?
$stderr.puts "-- stderr: --"
$stderr.print shell.stderr while shell.stderr?
end
validate myself but I cant seem to figure out how to 'cd' to another
directory besides my '/home' directory and then execute commands from
the new directory.
below is what I have so far and each time I execute this I receive the
below error
-----ERROR------
C:/ruby/test/SSHtest.rb:75: undefined method `shell' for
#<Net::SSH::Connection::Session:0x2e5bf30> (NoMethodError)
from c:/ruby/lib/ruby/site_ruby/1.8/net/ssh.rb:189:in `start'
from C:/ruby/test/SSHtest.rb:72
-----CODE-----
Net::SSH.start( "hostname", "username", assword => "Password" ) do
|session|
shell = session.shell.open
# script what we want to do
shell.pwd
shell.cd "/"
shell.pwd
shell.test "-e foo"
shell.cd "/file/trying/to/cd/to"
shell.send_data "program\n"
shell.pwd
shell.exit
# give the above commands sufficient time to terminate
sleep 0.5
# display the output
$stdout.print shell.stdout while shell.stdout?
$stderr.puts "-- stderr: --"
$stderr.print shell.stderr while shell.stderr?
end