tags:

views:

35

answers:

1

I'm trying to need to access/parse all outgoing connections on a particular port number on a Linux machine using a Python script. The simplest implementation seems to be to open a subprocess for netstat and parse its stdout.

I imagine someone somewhere has had this problem before, and am surprised not to find any netstat parsers online. Is this just not big enough of a problem for people to feel the need to share?

A: 

Instead of parsing output from netstat, you could look through the /proc entry for each process to see the open sockets. There's a rather simple perl script that does this that you could translate to python.

bstpierre