Way to get Code/path , which is executing under a process?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Way to get Code/path , which is executing under a process?
# 1  
Old 05-06-2014
Lightbulb Way to get Code/path , which is executing under a process?

Dear All,

Please help me in finding solution for below problem.

I need a command or script to get code or path(from which location code is being executed), which is executing under a process ID.

I dont have google access here,Please help me in finding solution.

Thank you.
# 2  
Old 05-06-2014
if you want the execution location from PID
Code:
readlink -f /proc/$PID/exe

If you want the script running under PID
Code:
ps -f $PID | awk 'NR > 1{for(i = 1; i <= 8; i++) $i=""; $0 = $0; $1 = $1; print}'

This User Gave Thanks to SriniShoo For This Post:
# 3  
Old 05-06-2014
Code:
lsof -p $PID

Under the column FD look for:
cwd: location where the script was started
txt: location where the executable lives
This User Gave Thanks to Aia For This Post:
# 4  
Old 05-15-2014
Thank you So much SriniShoo and Aia, working fine.
But I would like to explain my situation clearly.
I work in SAS technology, in our environment SAS installed in Unix OS, Inorder to execute SAS codes a unix script(default script) will get submitted at back end, That script in turn calls SAS code, So my need is to get SAS code. The commands which you have give working fine, when i submit your commands , i am getting the script, which is executing at back end, But i need SAS code.
Hope you got my point.
Is there any script/command to get SAS code.. i have googled it But i couldn't figure it.
Hope your experience and technical knowledge helps me.
Thank you.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to find the path of process in sunOS?

Please support for this issue, I have a below process running on my machine 16108 /usr/jdk/instances/jdk1.6.0/bin/java -Xms3072m -Xmx3072m -Dcbcm.root=/java3_app 20992 java -Djob.name=SOME_JOB_IS_RUNNING -Dcbcm.root=/java3_apps1/cbcm_js/j For PID 16108 I can see that its... (3 Replies)
Discussion started by: mirwasim
3 Replies

2. Shell Programming and Scripting

Loop to process 2 files with same name in different path

Hello forum members, I hope you can help me with this I don't know hot to reach. I have a list of files in "/home/MyPath1/" and in "/home/MyPath2/". The files have the same name in both folders. (but different content, the content doesn't matter here I think) /home/MyPath1/ filename1.txt... (4 Replies)
Discussion started by: Ophiuchus
4 Replies

3. AIX

tprof, truncate the process path

Hi, i tryed tprof -skex sleep 6 but... Process PID TID Total Kernel User Shared Other Java ======= === === ===== ====== ==== ====== ===== ==== wait 57372 77863 31.31 31.31 0.00 0.00 0.00 0.00 wait ... (1 Reply)
Discussion started by: zanac
1 Replies

4. Programming

Test Coverage - executing this code

Hi, I am trying to gain test coverage on the 'fold' program in unix and am having difficulty executing the following code: if(ferror (istream)) { error (0, errno, "%s", filename); if(!STREQ (filename, "-")) fclose (istream); return 1; } if (!STREQ (filename, "-") && fclose... (5 Replies)
Discussion started by: Jakeman1086
5 Replies

5. UNIX for Dummies Questions & Answers

Executing a sequence of commands as a single background process

I'm writing a PHP script which will take a given media file and convert it into a flash (flv) file. In addition to this, once the flv file has been generated I create two thumbnails (of different sizes) from the newly generated flv file. In order to do this I'm calling ffmpeg from the command... (4 Replies)
Discussion started by: phatphug
4 Replies

6. Shell Programming and Scripting

Executing Commands From Non-Standard Path (Changing user's PATH secretely???)

Hi: I have a requirement as below: I have some standard Unix commands modified and kept them in a directory say /usr/clsh/bin. For example I have a script named "ls" kept here which is modified version of "ls" (say it always gives long listing i.e. ls -l). When any user logs on and types... (2 Replies)
Discussion started by: ramesh_samane
2 Replies

7. Shell Programming and Scripting

executing code on files in the sorted order -help!

Say i have 2 files in the giving format: file1 1 2 3 4 1 2 3 4 1 2 3 4 file2 1 2 3 4 1 2 3 4 1 2 3 4 I have a PERL code (loaned by one of u -i forgot who - thanks!) that extracts the 2nd column from each file and append horizontally to a new file: perl -ane 'push @{$L->}, $F; close... (1 Reply)
Discussion started by: epi8
1 Replies

8. Programming

How to pass FIFO path to client process ?

Hello everybody ! I have a first program, called "server" which build 2 FIFO's in this way: ... #define PERMS 0666 #define FIFO1 "\tmp\cerere" #define FIFO2 "\tmp\raspuns" ... mkfifo(FIFO1, PERMS) mkfifo(FIFO2, PERMS) ... I want to access these FIFO's in a second separate program,... (1 Reply)
Discussion started by: Ametis1970
1 Replies

9. Shell Programming and Scripting

Full path of executing script in ksh?

Hello all, Here's the scenario: I've got a script, let's call it script1. This script invokes another script, which we'll call set_env, via the dot "." command, like so: File: #!/bin/ksh # region_id=DEV . set_env ${region_id} and so on. Script set_env sets up an... (2 Replies)
Discussion started by: BriceBu
2 Replies

10. UNIX for Advanced & Expert Users

process executable file full path

hi guys i give "ps -ef | grep some_executable_file" on the command line. this "some_executable_file" resides on many paths which r included in the PATH environment variable, so the output depicts only "some_executable_file" in the COMMAND column. how can i get the full path? thanx (3 Replies)
Discussion started by: xtrix
3 Replies
Login or Register to Ask a Question