Finding current working dir path


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Finding current working dir path
# 1  
Old 09-10-2001
Question Finding current working dir path

Hi Folks,

In a Unix (ksh) script, is there a way to determine the current working directory path of another logged-in user? Of course, I can use "pwd" to find my own path. But, how do I find it for another active user?

Thanks for any input you can provide. LY
# 2  
Old 09-10-2001
I'm not sure how you would do it in a script, or where exactly you could get the info from... maybe awk or grep... but you can get a user's current directory through finger.

Hope that helps... maybe someone else knows how to get it through a script for sure. Smilie
# 3  
Old 09-10-2001
Thanks for replying ober.

"finger" appears to only provide the logged-in users home directory and not the current working directory path they're in.
But, thanks for replying anyway. LY

Any other great ideas out there?
# 4  
Old 09-10-2001
There is a freeware program called "lsof" that can do this. Bear in mind that the user can be running several programs, each with a different current working directory. So you you will need to find a pid of a process that you're interested in. Then "lsof -p $pid" will show all files open by that process. And the current directory will have "cwd" in the FD column.
# 5  
Old 09-10-2001
my bad... that was before my caffine jolt for the morning... what was I thinking??? Smilie
# 6  
Old 09-10-2001
Perderabo,

Sounds great. Thanks much. I'll give it a shot.

Ober,

No problem. If I had a nickle for every "bad morning" I've had I'd be a very rich man.

Thanks all. LYSmilie
# 7  
Old 09-10-2001
Perderabo,

Thanks much. Sounds like that will work great. I'll give it a shot.

Ober5861

If I had a nickel for every "bad morning" I've had, I'd be a very wealthy guy.

Thanks all. LY
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Save all the file of current date in another dir?

Hi i want to copy all the files of current date in another directory. for example, below i want to save all the file of 26 march to copied in debug dir. $ ls -lrt | tail -5 -rwxrwxrwx 1 khare guest 73 Jan 6 12:35 chk -rw-r--r-- 1 khare guest 770 Mar 26 02:21 cc1... (2 Replies)
Discussion started by: scriptor
2 Replies

2. Shell Programming and Scripting

Finding DIR

Done this basic level script called mydir that prints the message File is a directory if the file is a directory. Code: #!/bin/kasha cat LIST | while read LINE do if ] then ls -ltr $LINE >out give=$LINE grep $1 out > out.txt grep ^d out.txt if ] ... (7 Replies)
Discussion started by: Roozo
7 Replies

3. Shell Programming and Scripting

how to copy current date files to another dir

i have directory /abcd and i want to copy all today date files in /xyz directory. i am able to see the files by using below command but not able to understand copy. find . -mtime -1 -type f -exec ls -l {} \; (2 Replies)
Discussion started by: learnbash
2 Replies

4. HP-UX

Unable to Set Prompt to current working DIR

HPUX does not recognise \h,\w,\u to display the hostname,working directory and username respectively. So how do i set the PS1 variable to display my current working Directory as my prompt? I also tried PS1=$PWD, But it keeps showing the same directory path as prompt which PWD was holding at... (3 Replies)
Discussion started by: Amit Kulkarni
3 Replies

5. Shell Programming and Scripting

"find . -printf" without prepended "." path? Getting path to current working directory?

If I enter (simplified): find . -printf "%p\n" then all files in the output are prepended by a "." like ./local/share/test23.log How can achieve that a.) the leading "./" is omitted and/or b.) the full path to the current directory is inserted (enclosed by brackets and a blank)... (1 Reply)
Discussion started by: pstein
1 Replies

6. UNIX and Linux Applications

CPIO Problem, copy to the root dir / instead of current dir

HI all, I got a CPIO archive that contains a unix filesystem that I try to extract, but it extract to the root dir / unstead of current dir, and happily it detects my file are newer otherwise it would have overwrited my system's file! I tried all these commands cpio -i --make-directories <... (2 Replies)
Discussion started by: nekkro-kvlt
2 Replies

7. Shell Programming and Scripting

How do I define a particular dir in PATH variable and then unset that dir

How do I define a particular dir in front of PATH variable and then run some job and then at the end of job SET the PATH variable to original? in a script, WILL something like this work: ORIG_PATH=$PATH export PATH=/dir1/dir2:$PATH RUN SOME JOBS ..... unset PATH EXPORT... (2 Replies)
Discussion started by: Hangman2
2 Replies

8. Shell Programming and Scripting

full path of a file situated either in parent's dir. or parent's parent dir. so on...

hi experts(novice people can stay away as it is no child's game), i am developing a script which works like recycle bin of windows. the problem i am facing is that when ever i am trying to delete a file which is situated in parent directory or parent's parent directory i am unable to... (1 Reply)
Discussion started by: yahoo!
1 Replies

9. Shell Programming and Scripting

calling current working dir from script

Hello, I am having problem in setting current working directory from shell. I want to set pwd as an environmental variable in a script. I am following an existing script which is defined as HOME=$(shell dirname `pwd`) C_HOME=$(shell echo $(HOME) | sed -e 's:\/:\\\/:g' ) But when I am trying... (3 Replies)
Discussion started by: chandra004
3 Replies

10. UNIX for Dummies Questions & Answers

using grep to find a value in current dir and sub dirs?

Hey guys, I would like to find all files which contain "client1.dat". I would like to search from the current directory and all subs and print out all the files that have this. Any help would be greatly appreciated. Thanks much. (10 Replies)
Discussion started by: ecupirate1998
10 Replies
Login or Register to Ask a Question