Приемы профессиональной работы в UNIX



         

Глава 05_1


содержит море(!) аналитической информации


Сервер поддерживается

Центром Информационных Технологий

(095) 932-9212, 932-9213, 939-0783

E-mail: info@citforum.ru

ИМЯ: timelog

timelog Учет и статистика времени

НАЗНАЧЕНИЕ

Интерфейсное меню для слежения и сопровождения файлов регистрации времени.

ФОРМАТ ВЫЗОВА

timelog

ПРИМЕР ВЫЗОВА

timelog Выводит на экран главное меню, из которого можно выбирать необходимое действие

ТЕКСТ ПРОГРАММЫ timelog

1 : 2 # @(#) timelog v1.0 Time accounting and statistics Author: Russ Sage 2а Учет и статистика времени   4 PROJ=""   6 while : 7 do 8 set `date` 9 echo "   11 $1, $2 $3 $4   13 Time Logger 14 ----------- Project: $PROJ 15 s) Select a project file 16 c) Create a new project file 17 l) List current project files 18 v) View the project file 19 n) Turn billing on 20 f) Turn billing off 21 r) Report ststistics   23 enter response (s,c,l,v,n,f,r,): \c"   25 read RSP   27 case $RSP in 28 "") break;; 29 s) echo "\Enter project name ( for exit): \c" 30 read PROJ2 31 if [ "$PROJ2" = "" ] 32 then continue 33 fi 34 if [ ! -s $PROJ2.time ] 35 then echo "you must specify a valid project file" 36 continue 37 fi 38 PROJ="$PROJ2";; 39 c) echo "\nEnter the new project name ( to exit): \c" 40 read PROJ2 41 if [ "PROJ2" = "" ] 42 then continue 43 fi 44 if [ -f "$PROJ2.time" ] 45 then echo "\n ** $PROJ2 already exists **" 46 continue 47 fi 48 PROJ="$PROJ2" 49 echo "\nProject file created: $PROJ" 50 echo "Project file created: `date`\nOFF: begin" > $PROJ.time;; 51 l) echo "\nCurrent project files:\n" 52 ls -l *.time 2>/dev/null echo "no project files" | 53 sed "s/\.time//";; 54 v) if [ "$PROJ" = "" ] 55 then echo "you must select a project file first" 56 continue 57 fi 58 echo "\n:----------------------------" 59 more $PROJ.time 60 echo ":---------------------------";; 61 n) if [ "$PROJ" = "" ] 62 then echo "you must select a project file first" 63 continue 64 fi 65 if [ "`tail -1 $PROJ.time|cut -d: -f1`" != "OFF" ] 66 then echo "logging was not turned off" 67 continue 68 fi 69 echo "\nBilling turned on for project file: $PROJ" 70 echo "ON: `date`" >> $PROJ.time;; 71 f) if [ "$PROJ" = "" ] 72 then echo "you must select a project file first" 73 continue 74 fi 75 if [ "`tail -1 $PROJ.time|cut -d: -f1`" != "ON" ] 76 then echo "logging was not turned on" 77 continue 78 fi 79 echo "\nBilling turned off for project file: $PROJ" 80 echo "OFF: `date`" >> $PROJ.time;; 81 r) while : 82 do 83 echo " 84 Statistics 85 ---------- Project: $PROJ 86 a) Accumulative time totals 87 n) All times on 88 f) All times off   90 enter response (a,n,f,): \c"   92 read RSP   94 case $RSP in 95 "") break;; 96 a) awk '/Total:/ { PRINT $0 }' $PROJ.TIME;; 97 n) awk '/ON/ { print $0 }' $PROJ.time;; 98 f) awk '/OFF/ { print $0 }' $PROJ.time;; 99 *) echo "\n ** Wrong command, try again **";; 100 esac 101 done;; 102 *) echo "\n ** Wrong command, try again **";; 103 esac 104 done




Содержание  Назад  Вперед