From: Harry Kakueki Date: 2009-08-21T16:17:30+09:00 Subject: Re: Showing dot each second until the script ends On Fri, Aug 21, 2009 at 3:35 PM, Hunt Jon wrote: > I have a ruby script, which takes about 20 seconds to execute. > > I want to show a dot (.) sign each second. > > I think I need to use "sleep" method and a loop, > but I don't know how to add the functionality to my script. > > Any help would be appreciated. > > If you want to do that I think you would need a thread for that purpose. Does your script now print nothing for that 20 seconds? If so, you could print a dot after each step of your program finishes. Then when you see the last dot, it will be finished, whether it took 19 seconds or 22 seconds, or whatever. Just a suggestion. (0..3_000_000).to_a #Fake busy time print "." STDOUT.flush (0..3_000_000).to_a #Next process, etc. print "." STDOUT.flush (0..3_000_000).to_a print "." STDOUT.flush (0..3_000_000).to_a print "." STDOUT.flush puts Harry -- A Look into Japanese Ruby List in English http://www.kakueki.com/ruby/list.html