Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Net::SSH performance question.

Reply
Thread Tools

Net::SSH performance question.

 
 
knohr
Guest
Posts: n/a
 
      05-07-2007
I am using Net::SSH to execute scripts on a remote server. The script
that it executes takes a long time to complete, and dumps allot of
stuff to stdout. If i allow the script to run as is, this causes ruby
(on the local machine) to eat up massive amounts of cycles, as it
parses the stdout. Redirecting the stdout to /dev/null on the remote
box will fix the performance issue, but will cause me to lose my SSH
session due to inactivity.

Is there is a way to optimize the following code, (maybe having STDOUT
have a low buffer size)?
keep in mind:
A: i need ssh session to be persistent
B: i cannot modify the settings on the server
C: i really don't want to rewrite the perl script *~2000 lines*
D: i would prefer that the script does not move past the shell.perl
line until the script has completed on the remote box.


Net::SSH.start('foo', :username=>'bar', assword=>'') do |session|
copy_file(session, '/tmp/file')
shell = session.shell.sync
shell.mv ("/tmp/file .")
shell.perl "test"
puts "done"
end

 
Reply With Quote
 
 
 
 
Robert Dober
Guest
Posts: n/a
 
      05-07-2007
On 5/7/07, knohr <(E-Mail Removed)> wrote:
> I am using Net::SSH to execute scripts on a remote server. The script
> that it executes takes a long time to complete, and dumps allot of
> stuff to stdout. If i allow the script to run as is, this causes ruby
> (on the local machine) to eat up massive amounts of cycles, as it
> parses the stdout. Redirecting the stdout to /dev/null on the remote
> box will fix the performance issue, but will cause me to lose my SSH
> session due to inactivity.
>
> Is there is a way to optimize the following code, (maybe having STDOUT
> have a low buffer size)?
> keep in mind:
> A: i need ssh session to be persistent
> B: i cannot modify the settings on the server
> C: i really don't want to rewrite the perl script *~2000 lines*
> D: i would prefer that the script does not move past the shell.perl
> line until the script has completed on the remote box.
>
>
> Net::SSH.start('foo', :username=>'bar', assword=>'') do |session|
> copy_file(session, '/tmp/file')
> shell = session.shell.sync
> shell.mv ("/tmp/file .")
> shell.perl "test"
> puts "done"
> end
>

Hmm there is one question I would have? What do you need as
result/output, if I understood correctly nothing?
In that case maybe not using shell should help, the following works
perfectly on my box

Net::SSH.start( 'localhost' ) do |session|
session.open_channel do | channel |
channel.on_data do | ch, data |
puts data
end
channel.exec "find /home/robert -exec ls -ltr {} \\; >/dev/null"
end
session.loop
end

It waits until the channel is closed.

HTH
Robert

--
You see things; and you say Why?
But I dream things that never were; and I say Why not?
-- George Bernard Shaw

 
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
Performance Tutorials Services - Boosting Performance by DisablingUnnecessary Services on Windows XP Home Edition Software Engineer Javascript 0 06-10-2011 02:18 AM
OCZ Rally High Performance USB2 (Dual Channel) Flash Memory Silverstrand Front Page News 0 09-20-2005 03:35 AM
How to quickly improve your computer's performance @ Bona... Silverstrand Front Page News 0 08-24-2005 01:26 PM
HEXUS.review: Rockdirect XTI 3.8 Performance Silverstrand Front Page News 0 08-08-2005 02:37 PM
Web Form Performance Versus Single File Performance jm ASP .Net 1 12-12-2003 11:14 PM



Advertisments