티스토리 뷰

 

 

- 로그 파일에서 변수로 날짜와 배포ID를 받아 배포 결과를 조회하는 스크립트
- shell : ksh
- 변수 : yyyymmdd, 배포ID

 

#!/bin/ksh

# Check if the number of arguments is correct
if [ $# -ne 2 ]; then
    echo "[Usage] : deploy_chk.sh yyyymmdd ID or deploy_chk.sh ID yyyymmdd"
    exit 1
fi

# Function to check if the argument is a date
is_date() {
    case $1 in
        [0-9][0-9][0-9][0-9][0-1][0-9][0-3][0-9]) return 0 ;;
        *) return 1 ;;
    esac
}

# Check and assign the date and ID based on the input
if is_date $1; then
    date=$1
    id=$2
elif is_date $2; then
    date=$2
    id=$1
else
    echo "Invalid input. Please provide a date in yyyymmdd format and an ID."
    exit 1
fi

# Extract year, month, and day from the date
Y_day=$(echo $date | cut -c 1-4)
M_day=$(echo $date | cut -c 5-6)
D_day=$(echo $date | cut -c 7-8)

# Check if the log file exists and then search for the ID and "결과"
log_file="/LOGS/klaf/.../webadmin.log.${Y_day}-${M_day}-${D_day}"
if [ -f $log_file ]; then
    grep "$id" $log_file | grep "결과"
else
    echo "Check Day or ID"
    exit 1
fi
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
글 보관함