#!/bin/sh
# $Header
#
# Piece of code to print the user of a connection on the netstat output.
# Written and distributed by Dan Bernstein with authd 3.01.
#
# Distributed as a test function for nidentd 
#
netstat -n -f inet \
| sed -n 's+^.....................\([^.]*\.[^.]*\.[^.]*\.[^.]*\)\.\([^ ]*\) *\([^.]*\.[^.]*\.[^.]*\.[^.]*\)\.\([^ ]*\).*$+ echo -n \3 \4 \1 \2" "\; ./tcpuname \3 \4 \1 \2 2>\&1+p' \
| sh \
| awk '!/ fatal:/ { printf "remote %-15s.%-5s   local %-15s.%-5s   user %s\n" , $1, $2, $3, $4, $5 }
