Get the name of the caller script in bash script

前端 未结 9 1846
长情又很酷
长情又很酷 2020-12-04 23:58

Let\'s assume I have 3 shell scripts:

script_1.sh

#!/bin/bash
./script_3.sh

script_2.sh



        
9条回答
  •  Happy的楠姐
    2020-12-05 00:01

    Declare this:

    PARENT_NAME=`ps -ocomm --no-header $PPID`
    

    Thus you'll get a nice variable $PARENT_NAME that holds the parent's name.

提交回复
热议问题