From: news on 10 Feb 2010 08:14 How do I find out which Desktop, VT is 'open on a particular directory'? lsof | grep <the application> shows the pidS of the several instances of <the application/Editor> running in various desktops and VTs. And it shows which dir. the editor has 'opened'. So, I get a list of dirs that are opened by the instances of <Editor>. NOW I want to know which Desktop/VT has got a particulat open-dir/Editor. Every time the editor [actually it's mc] changes to a different dir., this must be recorded. And I think it's available in some file. Since I've got the pid, /proc/<pid> seemed a likely place to find it. find /proc <all files which changes in the las 30 minutes> doesn't show me <which dir the editor was recently switched to>. When I've got 6 VTs running in a Desktop, apparently the [1 of several] desktops must keep updated file/s of the status of its apps. including VTs? == TIA.
From: Chris Davies on 10 Feb 2010 16:24 news <news(a)absamail.co.za> wrote: > How do I find out which Desktop, VT is 'open on a particular directory'? I don't think that question makes sense. Can you try explaining what you're trying to do, again, please. You mentioned editing a directory, which definitely doesn't make sense, as it's not possible. You also mention mc. But there's nothing that I can see that explains what you're really trying to achieve. You talked about lsof and /proc, so I'm going to try and guess that you might want to know what directory an instance of mc is currently examining. So: # Get a list of PIDs for all instances of "mc" ps -ef | awk 'substr($0,49) ~ /mc( .*)$/ {print $2}' # List the open files/directories for a process $P lsof -p "$P" # List the open files/directories for all instances of "mc" lsof -c '/^mc$/' # Show the current working directory (cwd) for a process $P ls -l /proc/$P/cwd Empirically, it appears that the version of "mc" I have just installed chdirs around as the user selects different directories, so the last option is probably the easiest for you. Assuming this is what you're wanting, of course. Chris
From: Joe Beanfish on 12 Feb 2010 14:17 news wrote: > How do I find out which Desktop, VT is 'open on a particular directory'? lsof DIRECTORY eg lsof $HOME > Every time the editor [actually it's mc] changes to a different dir., > this must be recorded. And I think it's available in some file. > > Since I've got the pid, /proc/<pid> seemed a likely place to find it. /proc/<pid>/cwd is a soft link to the processes current dir. > find /proc <all files which changes in the las 30 minutes> > doesn't show me <which dir the editor was recently switched to>. > > When I've got 6 VTs running in a Desktop, apparently the [1 of several] > desktops must keep updated file/s of the status of its apps. including VTs? Neither the desktop nor the vt have any idea what directory any other program such as your shell or mc are in. Don't be fooled by the title bar having the directory name in it. That's just those applications telling the vt to change it's title to the string they provide. Try one of these and watch the title bar change for 5 seconds. (Assuming xterm, gnome-terminal, or compatible) echo "\033]0;floobydust\007\c";sleep 5 or echo -e "\033]0;floobydust\007\c";sleep 5 In zsh I use the precmd() function to title my terminals precmd () { echo "\033]0;$SHORTHOST::$LOGNAME::$PWD\007\c" }
|
Pages: 1 Prev: Sluggish USB hard drives Next: is firewire on Fedora Core 12 built in? |