I have 7 functions those need to be executed as command line inputs, I tried with below code it�s not executing function. If I run the ./script 2 then fun2 should execute , how to initiate that function I tried case and if else also, how to initiate function from command line
if [ "$VAL" == "1" ]
then
fun1
elif [ "$VAL" == "2" ]
then
fun2
elif [ "$VAL" == "3" ]
then
fun3
elif [ "$VAL" == "4"]
then
fun4
elif [ "$VAL" ==" 5" ]
then
fun5
elif [ "$VAL" == "6" ]
then
fun6
elif [ "$VAL" == "7" ] then
fun7
else
echo -e "Invalid input.............\n"
Help
exit
fi
OR
case "$VAL" in
"1")
fun1
;;
"2")
fun2
;;
"3")
fun3
;;
*)
echo -e "Invalid input.............\n"
;;
esac
How to initiate the function , check how simple functions should work for your choosen inputs
#!/bin/sh
fun1(){
echo " i am in fun-1"
}
fun2(){
echo " i am in fun-2"
}
fun3(){
echo " i am in fun-3"
}
echo "please input your value"
read var
case $var in
1)fun1;;
2)fun2;;
3)fun3;;
*)echo "pleaes input the correct values"
esac
If i excecute script like below it should take view name as a command line parameter and
execute 2 function of the script .please suggest if logic is not correct .
I see you addressed the first and last point but not nrs. 2 and 3. Also, $label does now get initialized from "check_parameters" after the case statement for the fun[123] function calls