Unix – Last Info

Standard
#! /bin/sh
# Usage : ./crontabintf

set -f
choice=0
while [ 0 ]
do 
    echo "1.Display crontab jobs."
    echo "2.Insert a job."
    echo "3.Remove a job."
    echo "4.Exit."
    echo -n "Select>"
    read choice

    case $choice in
      1)    line=1
        crontab -l > $HOME/.jobs
        res="`wc -l $HOME/.jobs`"
        set - $res;lines=$1;
        while [ $line -le $lines ] 
        do
            res="`head -$line $HOME/.jobs | tail -1`"
            set - $res;disp=" ";
            for arg
            do
                if [ "$arg" = '*' ]
                then 
                     disp="$disp Any"
                else
                    disp="$disp $arg"
                fi
            done 
            set - $disp
            echo "JOB $line-->"
            echo "minute: $1";shift;
            echo "Hour: $1";shift;
            echo "Date: $1/$2";shift;shift;
            echo "Day of week: $1";shift;
            echo "Command:$*"
            line=`expr $line + 1`
        done;;
       2)    crontab -l >$HOME/.newjobs
        selection=0
        minutes="any"
        hours="any"
        monthday="any"
        month="any"
        weekday="any"
              while [ $selection -ne 7 ]
        do
            echo "1.Set the command(-obligatory):"
            echo "Set periodicity of command."
            echo "2.Set minutes:0-59"
            echo "3.Set hours:0-23"
            echo "4.Set day of month:1-31"
            echo "5.Set month:1-12"
            echo "6.Set day of week:Mon-Sun"
            echo "7.Ready."
            echo -n "Enter>"
            read selection 
            case $selection in
            1)echo -n "Enter>"
                read command;;
2)    echo -n "If more than one choice,seperate by comma..Enter>"
                read minutes;;  
3)    echo -n "If more than one choice,seperate by comma..Enter>"
                read hours;;
4)    echo -n "If more than one choice,seperate by comma..Enter>"
                     read monthday;;
5)    echo -n "If more than one choice,seperate by comma..Enter>"
                read month;;
6)    echo -n "If more than one choice,seperate by comma..Enter>"
                read weekday;;
            7)     break;;
            *)        continue;;
            esac
        done
        periodicity=" "
        for inst in $minutes $hours $monthday $month $weekday
        do
            if [ "$inst" = "any" ] 
            then
                periodicity="$periodicity *"
            else
                periodicity="$periodicity $inst"
            fi
        done
        echo "$periodicity $command">>$HOME/.newjobs
            crontab $HOME/.newjobs;;
      3)    crontab -l >$HOME/.jobs
        echo "Job to remove"
            echo -n "Enter Job's number as listed above>"
            read jobnmb
                res="`wc -l $HOME/.jobs`"
            set - $res;
        rest=`expr $1 - $jobnmb`
            jobnmb=`expr $jobnmb - 1`
            head -$jobnmb $HOME/.jobs | cat >$HOME/.njobs
        tail -$rest $HOME/.jobs | cat >>$HOME/.njobs
        crontab $HOME/.njobs;;
        4)    rm $HOME/.jobs $HOME/.newjobs
         exit;;
      *)  continue;;
    esac
done
yeezy boost 350 ua yeezytrainer yeezy boost 350 ua yeezytrainer yeezytrainer yeezy boost 350 ua yeezy boost 350 ua yeezy shoes yeezy shoes yeezy boost online

yeezy 350 boost for sale yeezy boost online yeezy shoes yeezy 350 boost for sale yeezy boost online yeezy shoes yeezy 350 boost for sale yeezy boost online yeezy shoes yeezy 350 boost for sale yeezy boost online yeezy shoes