[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: listen on tcp port and log input ??



Marcel Welschbillig <marcel@comdek.net.au> writes:

> Dose anybody know of any programs i could use to open a port on a
> debian box and log the data that comes in to a file ??
> 
> What i want to do is have a CISCO router send data that it recieves on
> an AUX port to a tcp port on a linux machine and log the data to a
> file. The data will be PBX billing data from a remote site.
> 
> Any clues would be great !

$ port="the port you want your cisco box to connect to"
$ host="the IP address your cisco box is going to be connecting from"
$ cat > /usr/local/bin/cisco-log <<EOD
#!/bin/bash
exec 2> >(while read line; do logger -i "\$line"; done)
exec cat >> /tmp/cisco-log
EOD
$ cat >> /etc/services <<EOD
cisco-log       $port/tcp       # Cisco log
EOD
$ cat >> /etc/hosts.allow <<EOD
cisco-log: $host
EOD
$ cat >> /etc/hosts.deny <<EOD
cisco-log: all
EOD
$ cat >> /etc/inetd.conf <<EOD
cisco-log stream  tcp wait nobody  /usr/sbin/tcpd /usr/local/bin/cisco-log
EOD
$ /etc/init.d/inetd reload
$ 

Here you go.

Note that if you type in the script in an editor, don't escape the
dollar in $line. It's escaped to avoid expansion in the here-document.

Phil.



Reply to: