Код скрипта cgi-local.sh


#!/bin/bash
# Simple CGI script
# UUID: 72353fda-9512-470a-8fec-6cadaf002052

echo Content-type: text/plain
echo ""

LOG_FILE=/var/www/stat/local.log

# Show NUM lines
if [ -n "$QUERY_STRING" ]; then
    NUM=$QUERY_STRING
else
    if [ -n "$1" ]; then
        NUM=$1
    else
	NUM=10
    fi
fi

echo "Current statistic:"
tail -n $NUM "$LOG_FILE" | sort -r
#-----------------------------------------