On Thursday, May 16, 2002, at 11:27 , Postman Pat wrote:
> Greetings, > I want to write a script that will check to see if it was called from > another script, if not it will display a message saying for instance this > script is meant to be called from other script & not run interactively for > instance otherwise if called from a script will do it's intended purpose. > .. > > Is there a way that I can actually get this working properly? the problem here is resolving whom your PPID is, and whether or not it is a shell/init - eg: a daemon, properly formed, that detached from the controlling terminal will become a child of init [jeeves:~] drieux% ps -ax -o user,pid,ppid,command | grep perl drieux 16512 1 perl myFunkyDaemon drieux 16524 16514 grep perl [jeeves:~] drieux% whereas commands that are called from a shell would be children of the terminal in which they were run, and hence its shell, [jeeves:~] drieux% ps -ax -o user,pid,ppid,command | grep 16514 drieux 16514 16513 -csh (csh) root 16526 16514 ps -ax -o user pid ppid command drieux 16527 16514 grep 16514 [jeeves:~] drieux% in this case the csh is a child of the Terminal which is a child of the window server which is a child of init. { similar paths occur for rlogin/rsh/telnet.... } So IF you know which script you expect to be called by then your path is really simple - since you need only check for your PPID - ASSUMING of course that you are expecting it to block until you finish.... http://www.wetware.com/drieux/pbl/Sys/myParent.txt provides an UGLY way to do it - and the url references to ways that would be, for me, more natural... the problem of course is making sure that this safety check makes reasonable sense in the long run to begin with. A great place for testing out ideas about Process Management.... but will this really solve the issue you want??? ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]