在Linux下可以使用bash maintain的$PPID變數再搭配ps指令就可以慢慢推敲出script file的呼叫關係。
直接看範例:
#!/bin/sh # file: test1.sh echo $0 echo "Execute by `ps -o comm -h --pid $PPID`" echo =========== ./test2.sh
#!/bin/sh # file: test2.sh echo $0 echo "Execute by `ps -o comm -h --pid $PPID`" echo =========== ./test3.sh
#!/bin/sh # file: test3.sh echo $0 echo "Execute by `ps -o comm -h --pid $PPID`" echo ===========
執行結果:
./test1.sh Execute by bash =========== ./test2.sh Execute by test1.sh =========== ./test3.sh Execute by test2.sh ===========
沒有留言:
張貼留言