Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Help with net-ssh 2.0

Reply
Thread Tools

Help with net-ssh 2.0

 
 
Jay Rajaram
Guest
Posts: n/a
 
      05-07-2008
Hi..,

I am trying to use net-ssh for executing unix level commands using
net-ssh across many servers. I am looking for an example that would
allow me to use net-ssh similar to EXPECT.

As a first step I tried the following:
__________________________________________________ _________________________

#!/usr/bin/ruby

require 'rubygems'
require 'net/ssh'

Net::SSH.start('myhostname', 'username', assword => "password") do
|ssh|

#I need to sudo further into a different account
#How do I open a channel with PTY for this as the
#sudo fails without a proper terminal.

ssh.open_channel do |channel|

channel.on_data { |ch, data| puts "stdout: #{data}" }
channel.on_extended_data { |ch, type, data| puts "stderr:
#{data}" }

#The following command produces output
channel.exec "hostname"

#The following doesnot produce any output
channel.exec "uptime"

end

#Not sure what is the purpose of the next statement
ssh.loop

end

__________________________________________________ _________________________


Would anyone please show me an example script of how to open a PTY
channel to make the sudo succeed and subsequently send commands and
receive output from stdout and stderror.

Thanks
Jay
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help Help Help Pentax S5i Help needed (Please) The Martian Digital Photography 14 06-20-2008 07:56 AM
HELP - HELP - HELP =?Utf-8?B?S2ltb24gSWZhbnRpZGlz?= ASP .Net 4 03-09-2006 12:46 PM
HELP WANTED HELP WANTED HELP WANTED Harvey ASP .Net 1 07-16-2004 01:12 PM
HELP WANTED HELP WANTED HELP WANTED Harvey ASP .Net 0 07-16-2004 10:00 AM
HELP! HELP! HELP! Opening Web Application Project Error =?Utf-8?B?dHJlbGxvdzQyMg==?= ASP .Net 0 02-20-2004 05:16 PM



Advertisments