Thread: Reading from a text file, or unix console screen

Reading from a text file, or unix console screen

From
Suro
Date:
Hi!

Can anyone tell me how can I insert an information from a text file to a
PostgreSQL database when the text file is continously being updated with a
new information.

Alternatively if I have a freebsd program which continously echoes to the
console screen some information, how can I insert that information to the
database and to correct columns, using some regular expressions method.

The information is like the following...
[PHP]
U:1.2.28, 9502935, 1(inactive),(absolute) bytes rx 0, tx 108, (absolute)
pkts rx 0, tx 1,
F:1.2.29, 9508081, 136.141.179.137, 137.141.179.159, 137, 137, 17(udp), 0,
0, 1, 17, None, 0, 134.141.179.156,
5-minute, low, none, 2, 295,
U:1.2.29, 9512536, 1(inactive), (absolute) bytes rx 0, tx 108, (absolute)
pkts rx 0, tx 1,
F:1.2.30, 9517114, 136.141.179.137, 137.141.179.159, 137, 137, 17(udp), 0,
0, 1, 17, None, 0, 134.141.179.156,
5-minute, low, none, 2, 295,
U:1.2.30, 9520537, 1(inactive), (absolute) bytes rx 0, tx 108, (absolute)
pkts rx 0, tx 1,
F:1.2.31, 9527415, 50.141.179.153, 136.141.179.137, 1345, 37, 17(udp), 0, 0,
17, 1, None, 0, 134.141.179.156,
5-minute, low, none, 111, 2,
F:1.2.32, 9527415, 136.141.179.137, 50.141.179.153, 37, 1345, 17(udp), 0, 0,
1, 0, None, 0, 134.141.179.156,
5-minute, low, none, 2, 3909,
U:1.2.32, 9531740, 1(inactive), (absolute) bytes rx 0, tx 64, (absolute)
pkts rx 0, tx 1,
U:1.2.31, 9531740, 1(inactive), (absolute) bytes rx 0, tx 46, (absolute)
pkts rx 0, tx 1,
F:1.2.33, 9535506, 50.141.179.150, 136.141.179.137, 1024, 37, 17(udp), 0, 0,
17, 1, None, 0, 134.141.179.156,
5-minute, low, none, 111, 2,
F:1.2.34, 9535506, 136.141.179.137, 50.141.179.150, 37, 1024, 17(udp), 0, 0,
1, 0, None, 0, 134.141.179.156,
5-minute, low, none, 2, 3595,
[/PHP]

Thanks in Advance!
--
View this message in context:
http://www.nabble.com/Reading-from-a-text-file%2C-or-unix-console-screen-tf3485879.html#a9731631
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


Re: Reading from a text file, or unix console screen

From
Richard Huxton
Date:
Suro wrote:
> Hi!
>
> Can anyone tell me how can I insert an information from a text file to a
> PostgreSQL database when the text file is continously being updated with a
> new information.
>
> Alternatively if I have a freebsd program which continously echoes to the
> console screen some information, how can I insert that information to the
> database and to correct columns, using some regular expressions method.

Sounds like you'll be wanting Perl and File::Tail (try search.cpan.org)

I'm sure Python and Ruby have their own versions too.

--
   Richard Huxton
   Archonet Ltd