[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Help with the ".times" command in ruby

Giovanni Hynson

4/29/2008 10:48:00 PM

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
"---------------------------------------------------------------------"
--
Posted via http://www.ruby-....

5 Answers

Craig Demyanovich

4/29/2008 10:56:00 PM

0

[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

Giovanni Hynson

4/29/2008 11:28:00 PM

0

Craig Demyanovich wrote:
> 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
--
Posted via http://www.ruby-....

Poetic Justice

10/27/2009 4:09:00 PM

0

KK wrote:
> On Tue, 27 Oct 2009 09:59:27 -0400, Demon Buddha wrote:
>
>> KK wrote:
>>
>>> I'm entitled to own firearms; that does not mean my ex-con felon
>>> neighbor should therefore be allowed also.
>> Sure he should. The important concept here is EX-con. That
>> means you are no longer a felon.
>
> No, it means you're no longer an imprisoned convict.

So there is no way to pay society for your crimes?

It is a life sentence, for committing fraud?

>> You therefore should return to full rights.
>> Otherwise you need to remain in your cage.
>
> When you start keeping violent criminals in prison for the rest of their
> lives (maybe make some room by emptying the cells of non-violent drug
> offenders) then w'll talk.
>
> Meantime, someone just out of prison (which is, really, criminal school)
> for armed robbery should *not* be able to lawfully own a firearm.

Demon Buddha

10/27/2009 5:36:00 PM

0

KK wrote:

> Meantime, someone just out of prison (which is, really, criminal school)
> for armed robbery should *not* be able to lawfully own a firearm.

You are, of course, entitled to your opinion, but allow me to point out
that the basis seems no in keeping with the basics of liberty and the
notion of debts paid.

Prescott Niles

10/27/2009 7:27:00 PM

0

Demon Buddha wrote:

> KK wrote:
>
>> Meantime, someone just out of prison (which is, really, criminal
>> school) for armed robbery should *not* be able to lawfully own a firearm.
>
>
> You are, of course, entitled to your opinion, but allow me to point
> out that the basis seems no in keeping with the basics of liberty and
> the notion of debts paid.

But until the laws change for the better, "Former" criminals are indeed
criminals for life, regardless of their release.

Like many other highly educated people, I do believe that once a person
is set free from their incarceration, any and all rights should be fully
restored when released back upon the streets.

So if you do NOT want a person to fully have all rights restored because
you don't trust them, why release them upon us "again" in the first place?

My "cure" for prison reform is simple.

MANDATORY hard labor!
They MUST grow and cultivate their own foods, with excess going to the
communities.

One channel on TV! The Food Channel!

No Smoking!
Daily Cavity searches!

10 hour work days 8 days a week, either planting/cultivating food,
AND/or fixing the infrastructure of cities and towns sewers, building
bridges, fixing levees, filling sand bags, rebuilding homes, and other
things that even Mike Rowe wouldn't do on:
http://dsc.discovery.com/fansites/dirtyjobs/dirt...

OUR PRISONS need to be so scary, that even the most stupid "would be"
criminals" would be terrified to be in one.

And none of that sissyified crap, where prisoners are seperated or
segregated, either!

Put anybody with anybody!
Rapists with bad Accountants!
The "Bloods" with the "Crips"... and accountants!
Bernie Madoff and the ghost of Michael Jackson!