In Unix, how can I tell if I’m inside of a ‘typescript’ command?

(You): In Unix, how can I tell if I’m inside of a ‘typescript’ command?

(Daniele): dani@gilean:~$ echo $PPID

2815

dani@gilean:~$ ps |grep $PPID

2815 ttys000 0:00.02 script

(Daniele): Uhm, i don’t know if PPID variabile is a UNIX standard or a Mac OS extension

(You): thanks. I get “undefined variable” when I try it — is there something more obvious? Does ‘script’ set an ENV variable or something like that?

(Daniele): With the -f flag ps shows also the parent pid, you can watch the pid of your shell (the $$ variable) and check if is father is a script process

(You): thanks. I was hoping something like shlvl would tell me (shlvl itself doesn’t work since I’m instead two screens).

(Daniele): i’m sorry

(You): no, thanks :) At least that helps if I can’t find an obvious way.

———————-

(Elias): That depends on that Unix system you are using. On Solaris, you can run the command “ptree $$” to see if typescript is part of your process tree. Other Unices have similar commands.

[Vark assigned category: Unix, more details]

This entry was posted in Barry After Vark. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *