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’, :password=>’’) do |session|
shell = session.shell.sync
shell.mv ("/tmp/file .")