I've a Java socket server program that is listening for requests, and using netstat, I can see that the connection is already open.
However as the process name (from ps -ef) is very long and I can't grep the program name. Can anyone advise how I find out the PID of the process? Can netstat or some other command tell me that?
This will search the fstat output for port 22, and then awk will give you the third column which is the PID for the process bound to the specified port. Replace 22 with whatever port number you are binding to (don't forget to leave in the colon symbol) and you should get the info you need. Column output and command line switches might be different! =)