Operating System - HP-UX
1826420 Members
3141 Online
109692 Solutions
New Discussion

Re: The working directory of a process

 
SOLVED
Go to solution
Walmsley Charles
Occasional Contributor

The working directory of a process

I'm on HP-UX 11.11, and I need to retreive the working directory of a process which is up and running. I can get this information from the proc directory on a Linux machine, or an AIX machine, but I cannot find out how to do it on HP-UX 11.11. I hope that someone will be kind enough to help me out.
7 REPLIES 7
Etienne Roseau
Frequent Advisor

Re: The working directory of a process

hi !
if i understand well, you just have to tip :
ps -ef | grep
and it will give you the path of your process
hth
E.
Fabian Briseño
Esteemed Contributor

Re: The working directory of a process

hello Walmsley.
ps -fe |grep is the correct response to your question.
Knowledge is power.
Heiner E. Lennackers
Respected Contributor
Solution

Re: The working directory of a process

Hi,

you can use the non-standard tool "lsof" to find the "cwd" of a running process. You can find it at the "porting and archive centre for HP-UX" e.g. http://hpux.asknet.de.

For example if you check the init process you get the following output:
# lsof -p 1
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
init 1 root cwd DIR 64,0x3 2048 2 /
init 1 root txt REG 64,0x3 311296 53 / (/dev/vg00/lvol3)
init 1 root 0u REG 64,0x3 3000 290 /etc/utmp
init 1 root 1u REG 64,0x3 8960 291 /etc/utmpx

HeL
if this makes any sense to you, you have a BIG problem
linuxfan
Honored Contributor

Re: The working directory of a process

ps does not report the path unless the process was started with the full path.

I agree with HeL. Your best bet is lsof.

You can also download lsof from http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/lsof-4.77/
They think they know but don't. At least I know I don't know - Socrates
Reshma Malusare
Trusted Contributor

Re: The working directory of a process

Hi Charles,
I think you want to get information for running process using HP-Unix commands,
I am agree with all above replies,but as you are new to HP-Unix, i like to give you some more information.
1> Ps command --> report process status.
ps prints information about selected processes. Use options to specify which processes to select and what information to print about them.To know more about options, have a look on follwoing document:
http://docs.hp.com/en/B2355-60130/ps.1.html

2> lsof command -->This is a public domain tool called lsof that can be pulled from the internet and built on HP-UX. It shows all the files open by all the processes on the system, so use it in conjunction with grep if you are looking for a particular directory on a particular disk. For example,

# lsof | grep /mydisk

will show all processes with open files on the /mydisk file system.
For more information,read following document:
http://h21007.www2.hp.com/dspp/tech/tech_TechSingleTipDetailPage_IDX/1,2366,1193,00.html?jumpid=reg_R1002_USEN

Here, i sugggest you go for lsof,it will solev your query.
Please also read:
http://forums1.itrc.hp.com/service/forums/helptips.do?#33 on how to reward any useful answers given to your questions.

Thanks & Regards
Reshma
SANTOSH S. MHASKAR
Trusted Contributor

Re: The working directory of a process

Hi Charles,

U use lsof for HPUX

http://hpux.connect.org.uk/hppd/hpux/Sysadmin/lsof-4.77/

the syntax is

# lsof -p PID

This will show you all open files used by process.

-santosh
Walmsley Charles
Occasional Contributor

Re: The working directory of a process

Any one of three out of the five answers I obtained would have completely solved my problem