clear ################################################################# # script_2, version 01, Claudio Rocha # # This is a Bourne Shell Script # # Usage: script_2 # # This Script is written "Homework" - Dr. Halasa # ################################################################# while true do clear user=`/usr/ucb/whoami` if [ $user = root ] then echo "Script will run all options, because you logged in as root" else echo "\n\n\n" echo "Warning...$user, some of the options may not work," echo " you must be logged as root to gain full" echo " menu options access" fi echo "\n\n" echo "Would you like to continue [y/n - default=n]:_\b\c" read ans ans=${ans:-n} if [ $ans = y ] then while true do clear echo echo ####################################################### echo " Utilitiers Menu" ####################################################### echo echo " 1 -- Display Calendar for Current Year" echo " 2 -- Display Calendar for Current Month" echo " 3 -- Display Current Date and Time" echo " 4 -- Display Users Without Password" echo " 5 -- Display Information Current Logged Users" echo " 6 -- Look for Files with Setuid Permissions" echo " 7 -- Look for Files Bigger than [n]MB" echo " 8 -- EXIT" echo echo " Please choose option: _\b\c" read option option=${option:-8} ############################################### # Check options for License Administration Menu ############################################### ######################### if [ $option = 1 ] then clear echo "##################################" echo "Display Calendar for Current Year" echo "##################################" echo year=`date |cut -d" " -f6` cal $year |more echo "Press Enter to continue..." read _ENTER ######################### elif [ $option = 2 ] then clear echo "##################################" echo "Display Calendar for Current Month" echo "##################################" echo monyh=`date |cut -d" " -f2` cal $month echo "Press Enter to continue..." read _ENTER ########################### elif [ $option = 3 ] then clear echo "#############################" echo "Display Current Date and Time" echo "#############################" echo date echo echo "Press Enter to continue..." read _ENTER ######################## elif [ $option = 4 ] then clear echo "##############################" echo "Display Users Without Password" echo "##############################" if [ $user = root ] then echo logins -p |more echo echo echo "Press Enter to continue..." read _ENTER else echo echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++" echo "+ +" echo "+ This option only works with root provilegies +" echo "+ +" echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++" echo echo "YOU MUST BE LOGGED IN AS ROOT TO READ THIS FILE..." echo echo "Press Enter to continue..." read _ENTER fi ####################### elif [ $option = 5 ] then clear echo "########################################" echo "Display Information Current Users Logged" echo "########################################" echo w echo echo "Press Enter to continue..." read _ENTER ####################### elif [ $option = 6 ] then clear echo "######################################" echo "Look for Files with setuid Permissions" echo "######################################" echo echo echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++" echo "+ +" echo "+ This option only works with root provilegies, +" echo "+ but you can still run it with limited access. +" echo "+ +" echo "+ >>>>>>>>>look for /tmp/chkuid.log<<<<<<<<<<<<< +" echo "+ +" echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++" echo echo "YOU MUST BE LOGGED IN AS ROOT TO READ THIS FILE..." echo echo "Press Enter to continue..." read _ENTER find / -user root -perm -4000 -exec ls -ldb {} \; > /tmp/chkuid.log echo echo echo "Press Enter to continue..." read _ENTER ####################### elif [ $option = 7 ] then clear echo "##################" echo "Look for Big Files" echo "##################" echo echo echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++" echo "+ +" echo "+ This option only works with root provilegies, +" echo "+ but you can still run it with limited access. +" echo "+ +" echo "+ >>>>>>>>>look for /tmp/chkbig.log<<<<<<<<<<<<< +" echo "+ +" echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++" echo echo "YOU MUST BE LOGGED IN AS ROOT TO FIND ALL THE FILES..." echo echo "Press Enter to continue..." read _ENTER echo echo "Choose the size of the files you would like to look" echo "The size must be in MB - e.g. 1=1MB, 2=2MB...n=nMB" echo echo "Look for files in my system bigger than [MB]: _\b\c" read size_big size=`expr $size_big \* 2048` echo read g find / -size +$size -type f > /tmp/chkbig.log echo echo echo "Press Enter to continue..." read _ENTER ####################### elif [ $option = 8 ] then echo echo "#####################################################" echo "Thanks -- Exiting License Administration Script....." echo "#####################################################" sleep 1 clear echo done. exit 15 else echo echo "Invalid Option" sleep 2 fi done elif [ $ans = n ] then echo "exiting script..." sleep 2 clear echo done. exit 15 else echo "Invalid Option!" sleep 2 fi done