#!/usr/bin/perl -w use strict; use DBI(); my $cdr_log_file = "/var/log/asterisk/my_log"; my $mysql_host = "localhost"; my $mysql_db = "user"; my $mysql_table = "tbl_data"; my $mysql_user = "user"; my $mysql_pwd = "xxx*"; #my @ARGV; my $insert_str; my $sth; my $cdate=$ARGV[0]; my $clang=$ARGV[1]; my $csrc=$ARGV[2]; my $ccode=$ARGV[3]; my $cuniqueid=$ARGV[4]; # Connect to database # print "Connecting to database...\n\n"; my $dbh = DBI->connect("DBI:mysql:database=$mysql_db;host=$mysql_host","$mysql_user","$mysql_pwd",{'RaiseError' => 1}); $insert_str = "insert into $mysql_table (data1, data2, data3, data4, data5) values (\"$cdate\", \"$clang\", \"$csrc\", \"$ccode\", \"$cuniqueid\");\n"; $sth = $dbh->prepare($insert_str); $sth->execute(); # print "."; $sth->finish(); $dbh->disconnect(); exit;