0

In my Project, I have to execute a command in remote machine. and also i have to capture and display the output of the command in realtime. for example, If i am running 'dir' command in remote machine,then i should display how many minutes it requires to execute( like 2 mins remaining) the command.

0

2 Answers 2

1

You can try using the ruby-progressbar gem and place the output in a file that you can read

require 'ruby-progressbar'
p = ProgressBar.create(:format => '%a %B %p%% %t')
=> #<ProgressBar:0/100>           

 def test(p)
    d = Dir.new('ank')
    d.each do |file|
      sleep 4
      puts file
      p.increment
    end
end
=> nil 


1.9.3-p545 :029 > test(p)
.
..me: 00:00:06 =1% Progress                                                                                                    
bare:                                          00:00:10 == 2% Progress                                                                                                  
baze:                                        00:00:14 === 3% Progress                                                                                                
fooe:                                       00:00:18 ==== 4% Progress                                                                                               
 => #<Dir:ank> =====                                                                                                5% Progress
Sign up to request clarification or add additional context in comments.

Comments

0

Take a look at this, i guess it answers at least one of your questions

But I don't know for sure how to easily provide you with the execution time of that command

You may probably need to run all possible commands to estimate their execution time first, and put that data in some storage (database for example).

Or you can create table to store that time and grow that table after each command execution, so when the user tries to run a command already existant in that table, you give the user time estimated last time it was run;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.