netstat -p, missing PID/program name

I have a netstat command set up with awk to show which ports my box is listening on. The -p switch shows the PID/program name, too, which ordinarily would be very handy. However, several entries show up as just "-" for the program name which makes it hard to identify what is keeping the port open. It is possible to find this out by issuing a separate lsof command, but what I want to know is why the program name is omitted in the first place in the netstat output and how this can be avoided. I'm guessing there may be different ways to instantiate processes that could help with avoiding this problem.

I really want to be able to see what programs are using my ports at a single glance.

try your netstat command with the '-l' option in addition to '-p'. It will show listening processes only. the '-' you are getting is probably for established connections, which aren't listening. I usually run 'netstat -tunlp' for the best results.

This has no effect on missing process names.