in reply to Can a script tell if it is being run from inside a script versus in an interactive terminal session?
It doesn't work all the time. If I run a short command, like echo, I don't get that PID:sleep 10 | perl -e '$ppid=getppid();$sibs=`pgrep -P $ppid`;print("MY P +ID: $$\nPARENT: $ppid\nSIBLINGS: $sibs\n")' MY PID: 79496 PARENT: 563 SIBLINGS: 79495
Plus, this doesn't tell me about whether or not I'm running inside a shell script. I couldn't find a perl module that does what pgrep does.echo test | perl -e '$ppid=getppid();$kids=`pgrep -P $ppid`;print("MY +PID: $$\nPARENT: $ppid\nSIBLINGS: $kids\n")' MY PID: 79493 PARENT: 563 SIBLINGS:
|
|---|