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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine environment vars for a given PID on Mac OS X 1

Status
Not open for further replies.

goBoating

Programmer
Feb 8, 2000
1,606
0
0
US
Is there no section of Mac OS X on Tek-Tips? There is a server version. Does it not make the grade to be in this section of TTs? Looked. Didn't see one. Anyway, here goes.


On Mac OS X, for a given process ID, what is the best/most direct way to determine the environment variables (e.g. PATH)? Must be able to query for any arbitrary environment variable. PATH is just the first example.

'lsof -a -p $PID -d cwd -F' gets some of it.

But, I don't see a way to get the PATH for the given PID, using lsof.

'ps -Ep $PID' gets some of it.

But, again, 'not comprehensive. It appears to give back only a portion of the 'environment' for the process.

On a number of other Linux/UNIX variants, you can look at '/proc//environ'. But, OS X apparently does not use that mechanism.


'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
'ps -Eww $PID' does the trick.

When using 'ps' in a terminal, 'ps' truncates its output to the width of the terminal. The 'ww' tells 'ps' to use as much width as necessary to display the info.

'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top