Click to See Complete Forum and Search --> : Obtaining current directory of non-root user


xerid
06-14-2001, 10:40 AM
I want to write something that will return the current directory of a user in a specific session. How can I determine (C or Perl) this as an administrator. Also, is there a way to find out all the sessions (and type) a user may have at any given point, this way I can choose which session to grab the directory info (or other information) from.

Strike
06-14-2001, 12:59 PM
Well, w tells you what commands are being executed by all logged in users. I don't know how to get their current directory, though. I know that you can get your OWN current directory with pwd.

xerid
06-14-2001, 01:36 PM
Well, I want to be able to keep tabs on where the user is moving through the file system, semi-real-time. Perhaps if I write my own *pwd* routine (from understanding how pwd does what it does on a coding level). What do you think the best thing to do is. I want to run the program and watch the user work, while keeping stats such as command currently running (and show them spawning and terminatng), current directory...and maybe even peek at output on commands. just a thought......

[GoRN]
06-14-2001, 02:02 PM
/proc/pidoftheirshell/cwd is a sym link to the current directory
play with the other things there, fun stuff.

-out-

Energon
06-15-2001, 01:04 AM
go w/ GoRN's suggestion... you can't say "what directory is so and so in" because they could have multiple shells open and be in multiple directories at one time... you have to go by what each shell they're running is doing and where it's at...