Hi,
I am writing an interactive shell script (ksh) but I have no idea how I could make a condition on it :
Variables :
rep_config="${rep_tools}/_CONFIG"
rep_config_old="${rep_config}/_PROTO_OLD"
Here is the interactice part :
lst_proto=$(cat ${rep_config}/*.cfg | grep "#nom_transfert#" | awk -F" " '{print $2}'|sort)
lst_proto_old=$(cat ${rep_config_old}/*.cfg | grep "#nom_transfert#" | awk -F" " '{print $2}'|sort)
echo "$lst_proto : "
echo " "
echo "--------OLD PROTOTYPE-------------"
echo "$lst_proto_old : \c"
read prototype
echo "-------------------------------------------"
echo "You have Chosen : $prototype \n"
echo "-------------------------------------------"
echo " "
Here is the idea :
The CAT command goes on 2 differents directory and then find inside on all configuation files the name of the data you want to choose. There one directory for the current data and another directory for the old data.
DIR1
IDEFIX.cfg
"#nom_transfert#" will return IDEFIX
DIR2
ASTERIX_old.cfg
"#nom_transfert#" will return ASTERIX
My needs is to create a condition that will say something like this :
If $prototype has been chosen from $ls_proto do this ..... otherwise do this ....
I did try to make something like :
cat ${rep_config}/*.cfg | grep "#nom_transfert#" | awk -F" " '{print $2}'|sort> listeprotocfg
cat ${rep_config_old}/*.cfg | grep "#nom_transfert#" | awk -F" " '{print $2}'|sort> listeprotocfg_old
#echo "$lst_proto : "
echo $(( cat listeprotocfg ))
echo " "
echo "--------OLD PROTOTYPE-------------"
echo " "
#echo "$lst_proto_old : \c"
echo $(( cat listeprotocfg_old ))
read prototype
type_proto=grep ${prototype} listeprotocfg
if type_proto="" then
# If the PROTYPE IS OLD
fic_tmp_arbo=${rep_tmp}/controleSTAF_arbo_branche.txt
rep_config="${rep_config}/_PROTO_OLD"
nom_fichier=grep $prototype $rep_config/* | awk -F":" '{print $1}'
else
fic_tmp_arbo=${rep_tmp}/controleSTAF_arbo_branche.txt
fi
echo "-------------------------------------------"
echo "YOU HAVE CHOSEN : $prototype \n"
echo "-------------------------------------------"
echo " "
As you can see it is not really good... I hope you will be able to help me to make it right.
Thanks