PID and program name from netstat.


 
Thread Tools Search this Thread
Operating Systems HP-UX PID and program name from netstat.
# 1  
Old 01-06-2015
PID and program name from netstat.

Hello All,

I am using netstat on HP-UX to retrieve the established network connections on my host. Can anyone please confirm how can I retrieve the PID and program name as well for these connections? These are available from the netstat version on Windows but I don't see PID and program name to be available from netstat on HP-UX.

Any help/pointers will be appreciated.

Thanks!
# 2  
Old 01-06-2015
Hello Happy83,

Here is an example for same, you can take it as a first start up step and let us know if this helps.(Not tested though)

Code:
for i in `netstat -anp | grep "http" | awk '{print $7}' | awk -F '/' '{print $1}' | uniq` ;  do ps -eo pid,uid,ruser,etime | grep $i ; done

Thanks,
R. Singh

Last edited by RavinderSingh13; 01-06-2015 at 06:54 AM..
# 3  
Old 01-06-2015
Is this from Hp-UX or some other OS?
# 4  
Old 01-06-2015
Obviously HP-UX netstat only looks in the one system table, and does not look into other tables.
Maybe lsof can do this.? Download/install lsof from itrc
# 5  
Old 01-06-2015
Hi Folks,

I guess usage of "lsof" needs super user priveleges. Is that correct?

Also, we need to run this netstat in a script on multiple HP-UX hosts in client's environment and we cant have lsof installed on each and every host. Is there any alternative to retrieve this?

Thanks.
# 6  
Old 01-06-2015
Quote:
Originally Posted by Happy83
Hi Folks,

I guess usage of "lsof" needs super user priveleges. Is that correct?
I don't know a UNIX tool to list what programs have what ports, which doesn't require elevated privileges.
# 7  
Old 01-06-2015
Quote:
Originally Posted by Corona688
I don't know a UNIX tool to list what programs have what ports, which doesn't require elevated privileges.
At least on Linux, "netstat -p" is doing that without requiring specific privileges.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

How to grep PID and program name from netstat in AIX?

Hi All, I am using netstat on AIX to grep info on all open connections. However, unlike on Linux(Centos), I do not get the PID and program name using netstat on AIX. I need this info to be clubbed along with the information retrieved using netstat version of AIX. Is there a way this can be... (1 Reply)
Discussion started by: Vipin Batra
1 Replies

2. Red Hat

netstat

Hi Can any body tell me about TIME_WAIT status meaning in the following command output. # netstat -anp|grep 5000 tcp 0 0 127.0.0.1:50006 0.0.0.0:* LISTEN 5058/ccsd tcp 0 0 0.0.0.0:50008 0.0.0.0:* ... (3 Replies)
Discussion started by: mastansaheb
3 Replies

3. Solaris

netstat -- what am i looking at?

Greetings to all, Here is a line of output from my netstat command cbp031.904 wdcprodhome.nfsd 98304 0 49640 0 ESTABLISHED The only thing i recognize is the unix machine "cbp031" but what is .904 and all the other data telling me? Thanks in advance. (3 Replies)
Discussion started by: Harleyrci
3 Replies

4. Programming

getting the pid of another C program with unix calls

I have a C program called server.c which is supposed to get the pid of another program, client.c, and send a signal to it, but I'm not sure how to do it. Server.c is first run in the background then client is run in the foreground. I tried pid_t pid; pid = system("pidof -s client.c");... (3 Replies)
Discussion started by: busdude
3 Replies

5. UNIX for Advanced & Expert Users

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.... (2 Replies)
Discussion started by: Bilge
2 Replies

6. UNIX for Dummies Questions & Answers

Need to get pid of a process and have to store the pid in a variable

Hi, I need to get the pid of a process and have to store the pid in a variable and i want to use this value(pid) of the variable for some process. Please can anyone tell me how to get the pid of a process and store it in a variable. please help me on this. Thanks in advance, Amudha (7 Replies)
Discussion started by: samudha
7 Replies

7. IP Networking

netstat

Hi what is the command to see the process name/application name along with the port number, connection status ... netstat is not giving process/application name Is there any way to know which application is holding which port? Thanks in advance (3 Replies)
Discussion started by: axes
3 Replies

8. UNIX for Dummies Questions & Answers

Session PID & socket connection pid

1. If I use an software application(which connects to the database in the server) in my local pc, how many PID should be registered? Would there be PID for the session and another PID for socket connection? 2. I noticed (through netstat) that when I logged in using the my software application,... (1 Reply)
Discussion started by: pcx26
1 Replies

9. Programming

printing ppid,child pid,pid

question: for the below program i just printed the value for pid, child pid and parent pid why does it give me 6 values? i assume ppid is 28086 but can't figure out why there are 5 values printed instead of just two! can someone comment on that! #include<stdio.h> #define DIM 8 int... (3 Replies)
Discussion started by: a25khan
3 Replies

10. IP Networking

Netstat

Giving netstat command on the prompt gives commands such as localhost.43592 localhost.35237 32768 0 32768 0 TIME_WAIT localhost.43594 localhost.43595 32768 0 32768 0 TIME_WAIT localhost.43598 localhost.35237 32768 0 32768 0 TIME_WAIT... (6 Replies)
Discussion started by: DPAI
6 Replies
Login or Register to Ask a Question