I have a bash-script that is called by another script or process. So script/process A calls script B.
I have access to change script B and i want to know the name (and path, if possible) of the script/process A.
What do i need to write into script B to echo/outout me the name of script/process A?
pstree is no option for me :/
Thanks in advance =)
To get the parent pid
echo "$PPID"
To get parent process path you can parse the full cmd
ps -o command= -p "$PPID" | awk '{print $1}'
Another option on most unix-based systems
awk '{print $1}' /proc/"$PPID"/cmdline
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With