Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Silly issue with if / else with pingecho
ga rg
5/29/2008 3:25:00 PM
I'm positive that this is something incredibly silly. I have a text file
with computer names. I'm assuming that if a computer returns a ping then
it exists. To check this I have the following in a script:
def computer_exists?(computername)
Ping.pingecho(computername)
end
file = File.new(FILENAME, "r")
while (line_item = file.gets)
line_item = line_item.gsub(/\s+$/, $/) #remove trailing white
space
puts "Working on #{line_item}"
if computer_exists?(line_item)
deploy(line_item)
else
puts "Timed out"
end
end
file.close
The file contains three computer items:
ComputerA
ComputerB
ComputerC
When I go to irb and I do Ping.pingecho('ComputerA') it turns it as
true. All three computer exist and are pingable. However, when I run the
above code, ruby outputs Computer A and Computer B as Timed out but
Computer C runs the deploy method.
If I add a ComputerD, then ComputerA,B,C say time out and only Computer
D runs the deploy method.
What have a messed up?
Thank you.
--
Posted via
http://www.ruby-...
.
1 Answer
ga rg
5/29/2008 3:38:00 PM
0
Argh... sorry. I just had to chomp the computername.
Argh!
Thanks for reading.
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Silly issue with if / else with pingecho
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password