I want to insert data from a fifo pipe into a mysql table

my script as follows:

 

        my $dbh = DBI->connect("DBI:mysql:database=sedb;host=hostip",

            "dbname", "uid",

            {'RaiseError' => 1});

 

 

        print "Reading from FIFO...\n";

 

        while (<FIFO>)

        {

          $inputline = $_;

          # Quit read loop when requested.

          last if($inputline =~ /quit/i);

 

          chop $inputline;

          $linenumber++;

          print "Got: [$inputline], ";

 

          # Insert data into table 'secresult ', using placeholders

          $dbh->do("INSERT INTO secresult VALUES (?, ?,?,?)",

                undef, $inputline, $inputline, $inputline, $inputline);

 

          print "inserted it.\n";

 

        }

 

 

        # Now retrieve data from the table.

        my $sth = $dbh->prepare("SELECT * FROM secresult");

        $sth->execute();

        while (my $ref = $sth->fetchrow_hashref()) {

          print "Found a row: id = $ref->{'id'}, line =
$ref->{'textline'}\n";

        }

 

        $sth->finish();

 

        # Disconnect from the database.

        $dbh->disconnect();

 

        exit;

 

my secresult table schema:

 

col1 varchar(10)

col2   varchar(20)        

col3   varchar(20)        

col4   varchar(20)

 

 

 

the command:

 

        echo Topology_Change Tue Feb 11 09:04:34 2014 CISCO-7609V  A
Spanning Tree Topology Change flapping flapping event for device "VLAN" at
-/Te1/0 on VLAN 1 in 5 seconds >> SEC_fifo

 

i want insert to my secresult table values (Topology_Change,Wed Feb  5
14:19:40 2014,CISCO-7431P,A Spanning Tree Topology Change flapping flapping
event for device "VLAN" at -/Te1/0 on VLAN 1 in 5 seconds )

 

but when i execute the command ,it's insert into secresult table 

 

values(Topology_C,Topology_Change Tue,Topology_Change Tue,Topology_Change
Tue Feb 11 09:)

 

Something Wrong With My Script 

Pls suggest approaches.

Thanks!!

------------------------------------------------------------------------------
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
Now with support for Jelly Bean, Bluetooth, Mapview and more.
Get your Android app in front of a whole new audience.  Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk
_______________________________________________
Simple-evcorr-users mailing list
Simple-evcorr-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users

Reply via email to