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/.