Help with the ".times" command in ruby

G

Giovanni Hynson

Hey guys,

I'm trying to run a section of my ruby script 5000 times.
Can someone show me how to do this, as I have no programming
experience. Once I log into the BDI-3000 via Telnet, I just need
to loop the section of the script from the date stamp line to the end
of the script for 5000 times.

Here's my script.

#!\ruby\bin\ruby.exe -w
require 'strscan'
require 'net/telnet'


$fileName = "Flash_Loop"
$outFile = File.new("..\\\Temp\\#{$fileName}.txt", "w")


$outFile.puts "Flash loop to test the stability of flash chip after
multiple flashes."

$dut_ip = "10.1.4.130"


Signal.trap("INT") do
puts "Received INT killing #{$$}"

end

tn = Net::Telnet.new("Host" => $dut_ip, "Prompt" => /Core#0>/) {|str|
print str }

#######Date Stamp#########################################
date_result = IO.popen("date /T", "w+")
buffer = date_result.readlines
puts buffer
$outFile.puts buffer
date_result.close
time_result = IO.popen("time /T", "w+")
buffer = time_result.readlines
puts buffer
$outFile.puts buffer
time_result.close
result = tn.cmd("unlock 0x50000000 0x20000 3") {|str| print str
str
}
$outFile.puts result
result = tn.cmd("erase 0x50000000 0x20000 3") {|str| print str
str
}
$outFile.puts result
result = tn.cmd("prog 0x50000000 redboot64.bin BIN") {|str| print str
str
}
$outFile.puts result
result = tn.cmd("verify") {|str| print str
str
}
$outFile.puts result

$outFile.puts
"---------------------------------------------------------------------"
 
C

Craig Demyanovich

[Note: parts of this message were removed to make it a legal post.]

You can use the times method like this:

5000.times do
# do some work
end

Regards,
Craig
 
G

Giovanni Hynson

Craig said:
You can use the times method like this:

5000.times do
# do some work
end

Regards,
Craig



Thanks Craig,

I inserted your code and it works perfect.

-GHynson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,089
Latest member
Ketologenic

Latest Threads

Top