A script is misbehaving. I need to know who calls that script, and who calls the calling script, and so on, only by modifying the misbehaving script.
This is similar to a stack-trace, but I am not interested in a call stack of function calls within a single bash script. Instead, I need the chain of executed programs/scripts that is initiated by my script.
A simple script I wrote some days ago...
... and a simple test.
I hope you like it.
adding pstree -p -u `whoami` >>output in your script will probably get you the information you need.
The simplest script which returns a stack trace with all callers:
You can use Bash Debugger http://bashdb.sourceforge.net/
Or, as mentioned in the previous comments, the
caller
bash built-in. See: http://wiki.bash-hackers.org/commands/builtin/callerAnother way to do it is to change PS4 and enable xtrace:
You could try something like