Hi All,
I have a shell script in Linux and it will be invoked by 2 methods,
1) An automated background process .
2) Logining into the box and directly executing the script.
I need to put a validation in my shell script such that it will be executed successfully on when an automated background process invokes it. When any user login and invoke it manually it should throw an error and exit. Please advise how this can be achieved inside my shell script
Thanks a lot for your reply. If I need to validate whether the process is invoked only from a particular parent (i,e automated background parent process p1), then how can I do the validation in the shell script?
Hi,
Actually, the script is invoked in background from harvest. So, In order to identify whether the script is invoked only from harvest and not in foreground or through anyother background process, I got the $PPID in myscript.ksh, it gives the details as,
So, In the current shell script(myscrip.ksh) how can I get the parent's parent process name(i,e, 22510, /host1harvest/dstart/harrefreshd 50000 /host1harvest/Harvestr/5) and validate it for harvest string. Please advise.
For question 2, please post your exact Operating System and version and what Shell you are using. It also helps to know if the script will be normally invoked by root or another named user.
In the situation where I don't want a script executed by accident I usually call the script with an activation parameter and exit if the correct parameter is not supplied.
So, will I get the process name as "/host1harvest/dstart/harrefreshd" if I use the below script. Please advise. I am sorry, if I had typed wrongly in my previous posts.
Thanks a lot. Now, instead of calling the BEGIN inside a ppid.awk file, I planned to use it in a function get_process_name(). When I used it in a method, I am not getting the process name. How to change ppid.awk into a function in shell script? please advise.