From: John Maclean Date: 2008-06-02T20:11:14+09:00 Subject: Re: Usin net/ssh library On Sun, 1 Jun 2008 18:23:25 +0900 Prasad Pednekar wrote: > > Hi, > I was using the net/ssh library in my code ro ssh to a particular > machine. > But I found that the ssh library goes directly to the shell prompt and > executes the commands. net/ssh uses the ssh2 protocol internally, I also > tried using ssh1 > but with no success. > > Initially the prompt that appears should have been something like ">>>>" > but > in my case after running the script it goes directly to the shell prompt > "$" by-passing the cli prompt. > > a. Why does this behaviour take place?? > > b. Is there a way to go to the initial cli prompt ?? > > > -P From `ri Net::SSH` Net::SSH.start("host", "user", :password => "password") do |ssh| result = ssh.exec!("ls -l") puts result end Sample of my own stuff... require 'rubygems' require 'net/ssh' server = "acid" user = "jayeola" Net::SSH.start(server, user) do |x| cmd2 = x.exec!("test -d /proc && echo \"OK\"").strip p cmd2 if cmd2 != "OK" p "no proc found" else p "got proc" end cmd3 = x.exec!("test -f /proc/partitions && echo \"OK\"") cmd4 = x.exec!("test -f /proc/diskstats && echo \"OK\"") end I'm using this library and it doesn't give me a prompt at all but runs the code as required. How are you using it?