# Ruby libpcap fails when passing command-line argument

**URL:** <https://www.ruby-forum.com/t/ruby-libpcap-fails-when-passing-command-line-argument/118697>\
**Category:** Ruby\
**Created:** [October 30, 2007, 6:44am UTC](https://www.ruby-forum.com/t/ruby-libpcap-fails-when-passing-command-line-argument/118697 "2007-10-30T06:44:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kenny\_roytman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/958977/32.png) [@kenny\_roytman](https://www.ruby-forum.com/u/kenny_roytman)\
**Post date:** [October 30, 2007, 6:44am UTC](https://www.ruby-forum.com/t/ruby-libpcap-fails-when-passing-command-line-argument/118697/1 "2007-10-30T06:44:29Z")

</div>

Hi,

Can someone please help me out here? I’m trying to use Ruby/Libpcap  
extension to write a rudimentary packet sniffer.

I downloaded ruby/libpcap 0.6 from  
[http://www.goto.info.waseda.ac.jp/~fukusima/ruby/pcap-e.html](http://www.goto.info.waseda.ac.jp/~fukusima/ruby/pcap-e.html).

The following code breaks when calling it from the command-line with a  
parameter, such as:

$\>ruby dumptraffic.rb en1  
/usr/local/lib/ruby/site\_ruby/1.8/universal-darwin8.0/pcap.bundle:  
warning: do not use Fixnums as Symbols  
/usr/local/lib/ruby/site\_ruby/1.8/universal-darwin8.0/pcap.bundle:  
warning: do not use Fixnums as Symbols  
/usr/local/lib/ruby/site\_ruby/1.8/universal-darwin8.0/pcap.bundle:  
warning: do not use Fixnums as Symbols  
setfilter: parse error  
$\>

The code:

------- start of code

require ‘pcaplet’

include Pcap

class Sniffer  
def sniff(d)  
pcaplet = Pcaplet.new("-i " + d)  
c = pcaplet.capture  
d = Dumper.open(c,“dump.txt”)

```
c.each_packet(50) { |pkt|
    if pkt.ip?
        d.dump(pkt)
        puts "hello from #{pkt.src.to_num_s}"
    end
}

pcaplet.close

```

end  
end

if **FILE** == $0  
d = ARGV[0]  
sniffit = Sniffer.new  
sniffit.sniff(d)  
end

---- end of code

Any help would be greatly appreciated. Thanks.

- kenny r.
