I need to call a function within a code with $database and $ service as the arguments How do I proceed ? and how would a function be defined and these two arguments would be used inside the function?
Below is the code in which there is a function call calc_pref_avail at last:
for service in `$ORACLE_HOME/bin/srvctl status service -d $database | awk '{print $2}'`
do
c="/product/10"
case $ORACLE_HOME in
*/product/10*)
Instance_pref=`$ORACLE_HOME/bin/srvctl config service -s $service -d $database | sed 's/\(.*: \)\(.*\)\( AVAIL:.*\)/\2/1;1q'`
Instance_avail=`$ORACLE_HOME/bin/srvctl config service -s $service -d $database | sed 's/\(.*AVAIL: \)\(.*\)/\2/g;1q'`;;
*)
calc_pref_avail;;
I need to pass $database and $ service as an argument to this function and suppose below is the way I define my function
Please help me how to pass an argument to function call and while defining function how to return value and get that variable in the code from where function is called
I need to get two values from this function as below:
if [ "${line:0:21}" = 'Preferred instances: ' ]; then
pref=($(echo "${line:21}"|sed 's/,/\n/g'));
else
avail=($(echo "${line:21}"|sed 's/,/\n/g'));
fi
I need values of $pref and $avail from this function.Is there a way to combine these values and return as a 1 value since I understand that a function can return a single value .Thereafter after returning these values I can again get the 2 values in the code from where I called this function