-2

suppose there is a script "/home/abc/test.go". Someone else went to another directory lets assume "/etc/random/" and executed the script "test.go".

Now I want to know from where the script was invoked.

Can anyone help me with the command to know from where the script was invoked(/etc/random/)??

I tried "lsof" but it gives the files that the script is working on and the location of the script(/home/abc/) but not from where it is invoked.

Note:- I don't want to use $pwd in the script. I am looking for a command that can just display the directory from where the mentioned script was executed(invoked).

1 Answers1

1

The current directory is stored in the variable $PWD.

You could store that value somewhere at the beginning of the script to e.g. output it or save it in a log.

dr_
  • 29,602
  • The script is executed by another user and We can't modify the script

    As an admin, I Just want to know the directory from where he executed the script

    I mean is there a general command to find that...??

    – Rajan Sharma Jun 18 '19 at 08:52
  • No, there isn't, unless you set up a complete audit system. You could also have a look at the user's shell history. – dr_ Jun 18 '19 at 09:11