From: Sven Schott Date: 2010-05-12T08:29:46+09:00 Subject: Re: Timeout Error in pingecho --000e0cd4cda27ddc20048659e6b7 Content-Type: text/plain; charset=ISO-8859-1 Hmmm, what platform are you running it from? Just ran in from Mac OS 10.5.8 with Ruby 1.8.7 and it ran fine (ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9.7.0]). Maybe a tcp stack implementation difference between platforms? I did notice you had some addresses that have colons in them (e.g. 123456:201.92.93). Still handled fine on my machine but maybe not on others. Anyone else? On Wed, May 12, 2010 at 8:49 AM, Sajjad Po wrote: > hi. > > i wrote a little script . (Mass IP Pinger) > But I got an error :-s > > Error : > --- > /usr/lib/ruby/1.8/timeout.rb:60:in `timeout': execution expired from > /usr/lib/ruby/1.8/ping.rb:46:in `pingecho' > from a.rb:27 > from a.rb:26:in `each' > from a.rb:26 > --- > and my script : > ---- > #!/usr/bin/env ruby > > #Mass IP Pinger By MagicCoder (MagicC0d3r@gmail.com) > # www.magiccoder.ir > #-f = File > #-t = Time Out #Defualt = 0.5 > #-p = Port #Defualt = 80 > # > #sample : ruby magic.rb -f ip.txt -t 1 -p 22 > #sample : ruby magic.rb -f ip.txt > > require 'ping' > > time_out = 0.5 #Defualt > port = 80 #Defualt > > length = 0 > while (length < ARGV.length) > file = ARGV[length+1] if ARGV[length] == '-f' > time_out = ARGV[length+1] if ARGV[length] == '-t' > port = ARGV[length+1] if ARGV[length] == '-p' > length += 1 > end > > if (file != nil) > File.open(file).each do |line| > result = Ping.pingecho(line.scan(/\d+.\d+.\d+.\d+/).to_s, > time_out.to_f , port.to_i) > if(result == true ) > puts line.scan(/\d+.\d+.\d+.\d+/).to_s+"\t\t\tIs Up" > else > puts line.scan(/\d+.\d+.\d+.\d+/).to_s+"\t\t\tIs Down" > end > end > puts "Finish ..." > else > puts "\n\nMass IP Pinger By MagicCoder > (MagicC0d3r@gmail.com)\n\t\twww.magiccoder.ir" > puts "\n-f = File\n-t = Time Out\t#Defualt = 0.5\n-p = > Port\t#Defualt = 80" > puts "\nsample : ruby magic.rb -f ip.txt -t 1 -p 22" > puts "sample : ruby magic.rb -f ip.txt\n\n" > end > ---- > > sh$ ruby magic.rb -f list.txt -t 0.5 -p 22 > for sample Attached list > > > Thank you . > > Attachments: > http://www.ruby-forum.com/attachment/4722/list.txt > > -- > Posted via http://www.ruby-forum.com/. > > --000e0cd4cda27ddc20048659e6b7--