How to tell where the execution is going on right now?
i have a very unique problem.
now i have a big shell script and within that shell script i hop from one place to another. now we have commands like pwd which tell u in which directory u are at a particular moment. similarly i wan to know of a command which call tell me that where my script is at a particular moment. e.g. Code:
cd directory1 so every time i change the directory within the code i want to list the complete path where i am. just like pwd directory gives me the path of where i am in the file system i want a command which can do exactly the same for the process being executed. |
Hmmm...
Code:
#!/bin/bash Code:
/tmp |
some how in my case it gives me the present working directory of where i am logged in at the time of the execution of the script and not the script itself.
|
Solaris has pwdx, under Linux, you can parse "ls -l /proc/$pid/pwd@" output.
|
buddy can u please explain a little about ur code.?
specially what is PID and what is pwd@? |
PID: process ID. Every process (program) that starts has a unique id. To see them, type
$ ps aux at the terminal. Note that you shouldn't type the $ sign. In relation to jlliagre's post, /proc/self/cwd might work a bit easier. bahadur, can you post the script you're working with, or at least some of it? That would make helping you a lot easier. Thanks, pcweirdo. |
here is the code
Code:
recursive() in all the places where i have used the variable $actualpath i would lilke to use the pwdx pid. now can any one just tell me how can a shell script obtain its ownprocess ID? |
Quote:
Quote:
Code:
myPid=$$ |
All times are GMT -5. The time now is 06:56 PM. |