Suppose I have two scripts named parent.sh
and child.sh
. The parent.sh
script contains bash child.sh
line and the child.sh
script contains echo "This is the child script"
.
Now, if the user executes the parent.sh
, it should simply call the child.sh
script and exit. But if the user executes the child.sh
script, it should produce some error saying only parent.sh can execute the child.sh script
.
Is there a way that I can achieve this type of behaviour of executing the scripts? This was just a small example, I have a huge set of scripts which a user can execute but these scripts should only
be executed by the parent
script.
This is just to make sure that the user doesn't executes the wrong script by mistake. I don't want to strip away the users read/write
permissions.
My requirements in a nut shell:
bash parent.sh -> execute bash child.sh -> execute something by child.sh