Problem to track process IDs in HP-UX machine

Hello All,

I need to track the exact process ID related to a particular application running on HP-UX machine. i.e. the exact functionality of fuser unix command.
fuser application.log // It gives the exact process ID for application.log
Since there is no provision for 'fuser' in HP-UX machine, please help me how I can achieve the same functionality.

Thanks & Regards
Abhishek

Hmmm...maybe this command?

Thnx Perderabo for your quick response.
But the problem is I don't have permission for fuser command. That is why I am in problem. That is why while using /usr/sbin/fuser it is giving me error "Permission denied".
So what I want to do is to write a script using some command like ps -ef etc. and get the exact output as fuser produce.
For example : fuser application.log OUTPUT- 21235 (i.e. PID)
Similarly I want to perform this using ps command or set of commands. Is there any way to do it ?

Waiting for your response.......

Thanks & Regards
Abhishek

No, ps does not have enough info. If lsof is installed on your system it may work for you. But lsof is not part of HP-UX and you cannot install it unless you are root.

I know ps command is not enough as I have tried a lot. Also you can consider me as a user.
I am not a root and hence for fuser I don't have permission and searching for the alternatives.
Can you please suggest me any as this is really important !!

Thnx for your assistance

I remember seing some issues due to a security patch...removing permissions on some commands...
So my point of vue is if you were not allowed to use fuser (I found a box like that...) the message would be: cannot execute:

ra:/opt/java/bin $ fuser -cu /opt
/usr/bin/ksh: fuser: cannot execute
ra:/opt/java/bin $ ll /usr/sbin/fuser
-r-xr--r-- 1 bin bin 24576 Aug 3 2000 /usr/sbin/fuser
ra:/opt/java/bin $ exit
ra:/opt/java/bin $ cd
ra:/home/vbe $ cp /usr/sbin/fuser .
ra:/home/vbe $ ll fuser
-r-xr--r-- 1 vbe bin 24576 Feb 1 15:32 fuser
ra:/home/vbe $ fuser -cu /opt
/opt: 3738mto(root) 3116mt(root) 3729mto(root) 3225mto(lp) 29018mcto(ratel) 3259mto(root) 3263mto(root) 3733mto(root) 3588mt(root) 3301mto(root) 3354mt(root) 3687co(nursery) 527mcto(omv) 3392mto(root) 3724mto(root) 3712mto(root) 3741mto(root) 4289mcto(omv) 3755mto(root) 4281mcto(omv) 27936c(ratel) 5320mto(root) 16447c(ratel) 7269mto(root) 4808mct(root) 5332mto(root) 5333mto(root) 1435mt(root) 29005c(ratel) 28971c(vbe) 14287c(vbe) 26547c(ratel) 28972c(vbe) 21845c(ratel) 14305mt(vbe) 1947co(nursery)

ra:/home/vbe $

So I wonder if it isnt more on the filesystem you have no rights...

Thanks for your response vbe, but still the problem exists. On copying the executable file /usr/sbin/fuser to my home directory and then giving all permissions, it says
bash: fuser: command not found.

export PATH=$PATH:$HOME:. (or the correct syntax for bash, I cant think of it at the moment (Alzeimer already?...))

Then try...

I am just confirming, please have a look into the steps I have written(as per the information given by you):

1) export PATH=/usr/local/bin/bash (syntax for bash)
2) /opt/java/bin $ fuser -cu /opt
3) user:/opt/java/bin $ ll /usr/sbin/fuser
-r-xr--r-- 1 bin bin 24576 Aug 3 2000 /usr/sbin/fuser
4) user:/opt/java/bin $ exit
5) user:/opt/java/bin $ cd
6) user:/home/userID $ cp /usr/sbin/fuser .
7) user:/home/userID $ ll fuser
-r-xr--r-- 1 userID bin 24576 Feb 1 15:32 fuser
8) user:/home/userID $ fuser -cu /opt

Please correct me if I am wrong.

Thanks a lot for your help.
I tried the one you have suggested and written a script for the set of commands.
It's working . Cool
Once again thanks a lot VBE, you have made my day

Hello vbe,

One last question for you :

in my script I have written
export PATH=$PATH:$HOME:/usr/local/bin/bash
cd /opt/java1.3/jre/bin
fuser $1

The script is working fine but from where it calls fuser command. Is it calling from /usr/sbin/ folder. If yes then why doesn't it get executed directly ?
Please suggest me how fuser works here ??

>export PATH=$PATH:$HOME:/usr/local/bin/bash

Here what puzzles me is /usr/local/bin/bash which has nothing to do in your path

I put in my previous reply a dot (.) at the end of the variable, for
1) security reasons
2) you may (dont laught it happened to a developper last week!) have a program in your $HOME with the name of a command or "official" program...

>Please suggest me how fuser works here ??
Look this display:
rat:/home/vbe $ which fuser
./fuser
rat:/home/vbe $ ll /usr/sbin/fuser
-r-xr--r-- 1 bin bin 24576 Aug 3 2000 /usr/sbin/fuser
rat:/home/vbe $
rat:/home/vbe $ cd /usr
rat:/usr $ which fuser
no fuser in /usr/bin /opt/ansic/bin /usr/ccs/bin /usr/contrib/bin /opt/nettladm/bin /opt/fc/bin /opt/fcms/bin /opt/upgrade/bin /opt/pd/bin /usr/dt/bin /usr/bin/X11 /usr/contrib/bin/X11 /opt/resmon/bin /opt/pred/bin /opt/hparray/bin /opt/ignite/bin /opt/langtools/bin /opt/imake/bin /opt/samba/bin /opt/tusc/bin /opt/hpnp//bin /opt/gcc/bin /opt/perf/bin /opt/prm/bin /opt/cobol/bin /opt/OV/bin/OpC /opt/graphics/common/bin /usr/sbin/diag/contrib /usr/sbin /sbin /usr/local/bin .

So for executables the system looks through you $PATH, since the "official" fuser is not executable for you it does not see it and continues its search... and finds the one in your home directory or wherever you put it (if you updated your PATH correctly...)

All the best

Thanks a lot man !!
I have changed my script as per your suggestions and Now I got it.

Youre welcome!

All the best