<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: get_ip code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 18 May 2008 14:43:19 GMT</pubDate>
    <description>DZone Snippets: get_ip code</description>
    <item>
      <title>IP Catcher</title>
      <link>http://snippets.dzone.com/posts/show/5430</link>
      <description>--Howto use--&lt;br /&gt;the command line:&lt;br /&gt;   ruby /path/to/ipcatcher.rb /path/to/filename&lt;br /&gt;the program will print all the ip addresses which is inside the file.&lt;br /&gt; the program doesn't print the same ip address twice. with no duplications.&lt;br /&gt;Done by &lt;a href="http://www.amerj.info"&gt;Amer Jazaerly&lt;/a&gt;.there is no copyright.&lt;br /&gt;have fun ;)&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/bin/ruby&lt;br /&gt;&lt;br /&gt;def get_ips(file)&lt;br /&gt;  ips = []&lt;br /&gt;  File.read(file).to_a.each do |place|&lt;br /&gt;    sf = 0&lt;br /&gt;    while sfn = place.index(/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/,sf)&lt;br /&gt;      sf = sfn + 3&lt;br /&gt;      ips &lt;&lt; $&amp;&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;  return ips&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;get_ips(ARGV[0]).uniq.each { |ip| puts ip }&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 26 Apr 2008 08:18:04 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5430</guid>
      <author>amer (Amer Jazaerly)</author>
    </item>
  </channel>
</rss>
