#! /opt/bin/dash # # os/prog/process-run/post.sh export PATH="/opt/bin:/bin:/usr/bin" #echo "Content-type: text/plain\n"; in=$(cat); echo "in = \"$in\""; exit echo "Content-type: text/html\n\nprocess-run" user=`echo "${REMOTE_USER}" | tr -dc '[:alnum:]' | tr '[:upper:]' '[:lower:]'` if [ -z "$user" ]; then echo "Bad user: ${REMOTE_USER} -> $user"; exit 1; fi if [ -n "$HTTP_HOST" ]; then cd /os/prog/process-run || exit 1; fi # tomato = #FF6347 # lightgreen = #90EE90 # in=$(cat | egrep -v '#FF6347|#90EE90') h=$(echo "$in" | awk '{ if( $2 == "P") { print $3; exit; }}') useed=$(echo "$in" | awk '{ if( $2 == "useed") { gsub(/[^0-9]/,"",$3); print $3; exit; }}') case "$h" in 3) p=3; s="123456789"; procs="5:40,5:50,5:60";; *) p=2; s="123456789"; procs="5:50,5:60";; esac if [ -n "$useed" ]; then seed="$useed" msg="- seed = $seed" else x=$(perl -e "print unpack(\"C*\",$user);"); seed="${s}${x}" #echo "
s = $s, x = $x, seed = $seed
" # debug msg="" fi echo "$user - process-run #$p results $msg

green = correct
    red = wrong

" out=$( (echo "$in"; python3 ./process-run.py -s "$seed" -l "$procs" -c | grep '^ *[1-9]' | sed -e 's/READY/R/g' -e 's/RUN:cpu/C/g' -e 's/RUN:io_done/I/g' -e 's/RUN:io/I/g' -e 's/WAITING/W/g' -e 's/DONE/D/g') | awk -v p="$p" 'BEGIN { n=0; print ""; for( pid=0; pidPID: "pid""; print ""; } { # each line of user input from process-run-post looks like: U t1p0 R # each line of input from ./process-run.py looks like: 1 R W ... if( $1 != "") { if( $1 == "U") t[$2]=$3; else { ++n; print ""; for( pid=0; pid"j""; } print ""; } } } END { ++n; print ""; for( pid=0; pid"j""; } print "
Time
"n"
"n"
"; }' ) if [ -z "$useed" ]; then bad=$(echo "$out" | grep "#FF6347" | wc -l) good=$(echo "$out" | grep "#90EE90" | wc -l) log=$(echo "$in" | tr -dc '[:alnum:]') echo "$(date) $user ${p}: good $good bad $bad in: $log" >> log fi echo "$out\n"