Search This Blog

Monday, May 23, 2011

Calling one linux scipt from another.

This might not be the general practice being followed by script writer .
Most of the time it is recommended to write a function inside a script and call it whenever necessary.

Create and in /usr/local/sbin

Parent Script.
# cat
# file
[[ -f /usr/local/sbin/ ]] && . /usr/local/sbin/
echo "Calling Function"
echo "Value of Var is $Var"
echo "Returning the control"

Child Script.
# cat
echo "Just testing here:)"
echo "Value of Var is $Var"

Now execute the parent script.

# ./
Calling Function
Value of Var is 123
Just testing here:)
Value of Var is 123
Returning the control

No comments:

Post a Comment