I guessed that I could find something it the /proc directory, so I got into and found that for each running process there's a file called 'environ', which can be found in /proc/PID/environ. Ok, so that's fine and it would be a great solution, provided my problem was in a linux box, but it was Solaris 5.9 machine, and in solaris the /proc file, though it exists, it's not so full of information as in linux. And there was no environ file.
Fortunately I found on the web (I don't have the url anymore, sorry) that you can do something like:
ps wwe
to get the what I was looking for, and this works on linux and solaris. For example, to get the environment of my running bash session:
testing@fixdebian:~$ ps wwe $$
PID TTY STAT TIME COMMAND
27857 pts/6 S 0:00 -su TERM=xterm PATH=/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games LANG=es_ES@euro MAIL=/var/mail/testing HOME=/home/testing SHELL=/bin/bash USER=testing LOGNAME=testing
which is far more elegant. And this solved my problem in a more general way.
No comments:
Post a Comment