Show progress in scripting

Contents

Show Progress in bash/ksh

coming soon

Show progress in Perl

coming soon

Show progress in ruby

The example below implements a simple spinning progress bar in ruby with a Fiber.

simpleProgress.rb

#!/usr/bin/ruby 

class Progress

attr :progressFiber

def initialize

@progressArray=%w(| / - \\)

@progressFiber = Fiber.new do

print " "
counter=0

loop do

@progressArray.each do |c|

print "\b"
print c
Fiber.yield(counter+=1)

end
end

end

end

def tick

@progressFiber.resume

end
 
end

letsProgress.rb

 #!/usr/bin/ruby 
require_relative "simpleProgress"

th=Thread.new("Thread...") do

p=Progress.new

loop do

p.tick sleep 0.25
end

end

sleep 60