Link to home
Create AccountLog in
Avatar of cdukes
cdukesFlag for United States of America

asked on

CSV2Syslog perl script

Hi Perl junkies :-)

Is there a way to parse a .csv file and convert the strings to syslog?
I want to take in a log file and forward the information to a syslog server.

Thanks!
Avatar of cdukes
cdukes
Flag of United States of America image

ASKER

I should mention that the csv files are on a windows box, so using logger is out :-(
Avatar of Romi Kuntsman
Converting formats is always possible, and even easy with perl.

What fields are there in the csv file, and what format is the syslog file?

RK.
Avatar of cdukes

ASKER

I think the tricky part is going to be taking in text and pushing the data out to udp port 161

so let's say I  have a line of text:
03/28/2006,10:00:00,Authen OK,cisco,Engineering,10.1.1.2,tty130,20.1.1.1

These fields are as follows:
$DATE, $TIME, $MSG, $USER, $GROUP, $CALLERID, $NASPRT, $NASIP

So I need to read each line with these tokens and spit them out to a syslog server.
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of cdukes

ASKER

Nice!
Does this just log to the local syslog service? What if it's on winders?
Avatar of cdukes

ASKER

Also, how do I read the values from a .csv file instead of declaring $_ ?
while( <> ){
my($DATE, $TIME, $MSG, $USER, $GROUP, $CALLERID, $NASPRT, $NASIP) = split/,/;
...
}


Net::Syslog talks to any syslogd you can reach over the net.
You can set SyslogHost to the address of the remote syslogd