I have a script that reads Wireshark decoded output via a pipe, parses, and loads it into a MySQL table.

My current method involves writing the parsed delimited records to a file and then doing a "load data infile" to load MySQL.

This method is 50% faster than directly inserting each parsed record via DBI.

To make this even faster, I thought I'd like to try writing/loading data through a FIFO as shown on MySQL's LOAD DATA INFILE Syntax page but I can't seem to open the FIFO.

From the command line or within perl, I can create the FIFO with no problem. What I can't do is open it using either open or sysopen, the latter method taken directly from the named pipes example in Programming Perl.

The script just hangs at that point with no error.

I made the following example that simply opens then closes the fifo and it also hangs. It prints the warning but never returns a prompt

my $fifo = "fifo"; require POSIX; POSIX::mkfifo($fifo, 0666) or die "can't mknod $fifo: $!"; warn "$0: created $fifo as named pipe\n"; sysopen(FIFO, $fifo, O_WRONLY) or die "can't write $fifo: $!"; close FIFO;

I'm running this on Ubuntu 8.04 but I've also tried the code on Solaris 10 x86 with the same result.

Any guidance greatly appreciated. thanks.


In reply to Trouble opening FIFO for speedy MySQL loading by ultrachrome

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.