Guys I''m having a problem with net-ssh, its kinda taking too long to
execute a command and give me the results. It takes around 40 seonds to
do it. And  I have 3-4 commands to run on the remote box. Is there any
possibility to speed up the process. Im using the commands to run on a
CISCO BTS server. Is there any possibility that I cud keep  channel or
session open as long s i could and get the results. Each command I run
depends on the result of the previous one I run. Since we have to send
the exit command to get the ondata, its not helping much in speeding the
whole process. Can anyone help me out there to speed this whole porcess.
Thanks GUys, heres the code below :
    def execute_cmd(ssh_ssn, cmd_string)
      $cmd_rslt = ""
      $cmd_done = false
      puts "executing command: #{cmd_string} in session #{ssh_ssn}"
      begin
        ssh_ssn.open_channel do |channel|
          channel.on_success do
            puts "pty requested successfully!"
            channel.on_success do
              puts "shell started successfully!"
              channel.send_data cmd_string + "\n"
              channel.send_data "exit\n"
            end
            channel.on_data do |ch,data|
              #puts "rcvd #{data}"
              $cmd_rslt << data
            end
            channel.send_request "shell", nil, true
          end
          channel.on_failure do
            puts "shell could not be started!"
          end
          channel.on_close do
            puts "shell terminated"
            $cmd_done = true
          end
          channel.request_pty :want_reply => true
        end
      rescue Exception => myexp
        puts myexp
        $cmd_rslt = ""
      ensure
        $cmd_done = true
      end
    end
-- 
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
James George wrote:> Guys I''m having a problem with net-ssh, its kinda taking too long to > execute a command and give me the results. It takes around 40 seonds to > do it.Almost sounds like a reverse DNS lookup problem on the Server. On the target server, if you do a "nslookup x.x.x.x" with the IP address of the client machine, does it return the host name right away? If not, your connection is taking so long because sshd is timing out on the reverse DNS lookup for the client''s IP address. If this is the problem, then you need to either set up DNS on the server to know the reverse DNS for the IP address of the client, or perhaps change UseDNS no in /etc/ssh/sshd_config. As per keeping the connection Open, I''m not sure about net-ssh but you could use the OpenSSH command line to do port forwarding or a VPN that is always open... Hope this helps, -- http://myutil.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
face wrote:> James George wrote: >> Guys I''m having a problem with net-ssh, its kinda taking too long to >> execute a command and give me the results. It takes around 40 seonds to >> do it. > Almost sounds like a reverse DNS lookup problem on the Server. On > the target server, if you do a "nslookup x.x.x.x" with the IP address > of the client machine, does it return the host name right away? > If not, your connection is taking so long because sshd is timing > out on the reverse DNS lookup for the client''s IP address. > > If this is the problem, then you need to either set up DNS on the > server to know the reverse DNS for the IP address of the client, or > perhaps change UseDNS no in /etc/ssh/sshd_config. > > As per keeping the connection Open, I''m not sure about net-ssh but > you could use the OpenSSH command line to do port forwarding or > a VPN that is always open... > > Hope this helps, >Oops I missed the part of the "CISCO BTS server"...so the server config might be a little different, but it still sounds like a Reverse DNS issue, so if you fix the DNS server that the Cisco is talking to, it should fix your problem (if that is what it is). Thanks, -rm -- http://myutil.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
When I do the whole process of ssh into the box and run the commands, it works much faster through the normal command line. Its when I try to run this via the ruby application. It takes time like close to 40 seconds. The target server box is a BTS switch and I dont think we have any access to do the dns part in there. But the funny thing is that it all works at a blazing speed when attempted through the normal command line interface. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
James George wrote:> When I do the whole process of ssh into the box and run the commands, it > works much faster through the normal command line. Its when I try to run > this via the ruby application. It takes time like close to 40 seconds. > The target server box is a BTS switch and I dont think we have any > access to do the dns part in there. But the funny thing is that it all > works at a blazing speed when attempted through the normal command line > interface. >I tested your code on a standard sshd server and it was very fast (on net-ssh 1.1.2 and OpenSSH_4.7). But it seems like "SyncShell Service" might work for you original question about keeping the shell open: http://net-ssh.rubyforge.org/chapter-5.html#s4 Thanks, -rm -- http://myutil.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---