#! /bin/ksh # homework2 # Nathan Balon # SN 797737 echo Enter the name of the file you want to create read filename echo `touch $filename` echo > $filename echo " my_monitered program 2" >> $filename echo >> $filename echo The name of the file is: $filename >> $filename echo >> $filename echo Today is: `date +%A` >> $filename echo This month is: `date +%B` >> $filename echo Year: `date +%Y` >> $filename echo " Info About My Node" >> $filename is416_on=`who|grep 4161|wc -l` echo Number of is416 students currently using my node: "$is416_on" >> $filename auth_users=`ypcat passwd|wc -l` echo Number of authorized users: "$auth_users" >> $filename users_on=`rwho|wc -l` not_on=`expr $auth_users - $users_on` echo Number of authorizes users who are not currently logged in: "$not_on" >> $filename is416_total=`ypcat passwd|grep 4161|cut -f5 -d":"|wc -l` is416_not_on_node=`expr $is416_total - $is416_on` echo Number of is416 students currently not using my node: "$is416_not_on_node" >> $filename echo >> $filename echo >> $filename echo " IS 416 Students Currently on my Node" >> $filename echo "User\ttty\tfrom\tlogin@\t\tidle\tJCPU\tPCPU\twhat" >> $filename echo "-------------------------------------------------------------------------" >> $filename w -h|grep 4161|tr -s " " "*" > my_monitered_file w -h|grep 4161 >> $filename chmod 700 my_monitered_file Mail -s "Monitered report for is416 students" `whoami` < $filename echo >> $filename echo >> $filename echo " The First Three IS4161 Students Email Message" >> $filename echo "------------------------------------------------------------------------" >> $filename for i in 1 2 3 do read line #echo $line touch email_report name=`echo $line |cut -f1 -d"*"` uname=`ypcat passwd|grep $name|cut -f5 -d":"` echo >> $filename echo hi $uname > email_report terminal=`echo $line|cut -f2 -d"*"` echo You were using Terminal "$terminal" >> email_report ip=`echo $line|cut -f3 -d"*"` echo Your IP address was "$ip" >> email_report loggin=`echo $line| cut -f4 -d"*"` echo You logged in at "$loggin" >> email_report command=`echo $line|cut -f6,7,8 -d"*"|tr "*" " "` echo You were executing the command $command >> email_report cat email_report >> $filename Mail -s "Monitered Report" $name < email_report done < my_monitered_file