I have a Shell Script to do 4 tasks within a menu. The code I have so far is (basic one i guess) without a menu. I wanted it to add the menu at the start and i have tried many ways (using case statement, if else and while loop). Nothing has been worked out.
#!/bin/bash
cd /
echo "1. Basic Details"
echo "2. CPU Information"
echo "3. Network information"
echo "4. All"
echo "5. Cancel"
read option
if [ $option -eq 1 ];then
echo ">>>>> Server Name, Date, UPtime <<<<<"
echo "====================================="
echo "Date :- `date`"
echo " "
echo "Host Name :- `hostname`"
echo " "
echo " OS Version"
oslevel -g
echo " "
echo " UPTIME :- "
uptime
echo " "
echo " "
elif [ $option -eq 2 ];then
echo ">>>>> CPU and Memory Info. <<<<<"
echo "====================================="
echo " "
echo
echo " CPU :- `lsdev | grep Processor | wc -l`"
echo " "
echo " Memory :- `lsattr -El mem0 | tail -1`"
echo " "
echo " "
echo "====================================="
echo ">>>>> Important Kernel Params. <<<<<"
echo "====================================="
echo " "
echo "****************************************"
echo " "
lsattr -El aio0
elif [ $option -eq 3 ];then
echo ">>>>> Memory Usage Information <<<<<"
um=`svmon -G | head -2|tail -1| awk {'print $3'}`
um=`expr $um / 256`
tm=`lsattr -El sys0 -a realmem | awk {'print $2'}`
tm=`expr $tm / 1024`
fm=`expr $tm - $um`
ump=`expr $um \* 100`
ump=`expr $ump / $tm`
echo " "
echo "Memory Used :- "$ump"%"
echo " "
echo "----------------------";
echo "Memory Information\n";
echo "total memory = $tm MB"
echo "free memory = $fm MB"
echo "used memory = $um MB"
echo "-----------------------\n";
echo " "
echo " "
else
echo "Enter correct option"
fi
Please suggest with corrections. Not added the option 4 in script( i need it to display all the information)
select..inconstruct. Beyond that, it is difficult to offer solutions when the problem statement is simply, "it doesn't work". Please edit your question to give a more complete description of what you expected to happen and how that differs from the actual results. See How to Ask for hints on what makes a good explanation.