Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Easy question: how to get the working directory for a process?

Status
Not open for further replies.

tomecki24

Programmer
Jun 13, 2001
52
DE
Hello,

I've got a question:
How to get the working directory for a process?
I mean when I do: ps -ef | grep MyProcess
I'm getting whole description and CMD info. But the CMD is very short and when I start next MyProcess I don't know which one is first which is second.

In CMD I've got something like this:
user1 13700 13699 0 12:31:11 pts/6 0:10 /usr/tibco/sap/bin/r3Adapter -system:repourl tibcr://TestBAPI:subject=com.tibco

but the interesting info comes after this line.
How to see whole line or how to check from where (directory) this command was called.

Thanks a lot

Tomasz
 
Not quite sure if this is what you mean, but you should be able to tell which is first and which is second using the PID of the process. The lower the number, the earlier the process was started. HTH.
 
Hello,

I will explain it better:
I've got some sapAdapters. Each one is started by the same program but has different configuration file.

For example full path is this:
/usr/tibco/sap/bin/r3Adapter -system:repourl tibcr://Repo:subject=com.tibco.repo.instance_discovery.request:daemon=tcp:IP:7500:network=IP:service=7500 -system:configurl /tibco/private/adapter/SAPAdapter30/bank

but ps -aef displays only:
/usr/tibco/sap/bin/r3Adapter -system:repourl tibcr://TestBAPI:subject=com.tibco

When I have started three of them and I want to kill one, I don't know which one is the one I need, because I can't see the whole line.

How can I see it?

Thanks
Tomasz
 
Your lines quite long...
does this command make any difference

ps -u root -o user -o "args=LONG COMMAND"
| grep "/usr/tibco/sap"
 
Hello,

I can't see the whole line with this command.
Is there any other solution?

Thanks a lot
Tomasz
 
Thomas,

Could you save the PID of each adaptor as you start them up? Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Hello,

I'm starting them and I'm redirecting the output to log file.
How can I save the PID during start?

All this is done under Solaris 7.

Thanks
Tomasz
 
ok - if you start them like this (assuming that the command is named 'adapt')

adapt &

this will run adapt in the background and the the PID is available to you in $?

so, in your shell script:

adapt&
pid=$?
print $pid > /tmp/adapt.pid

and the PID of the adapt process you've just started will be in the file /tmp/adapt.pid Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top