Skip to content
  • #!/bin/bash

    Set content type

    echo "Content-type: text/html" echo ""

    Start HTML output

    printf "\n

    \nCGI Example\n\n\n"

    Extract fields from packet

    MAGIC=$(echo $QUERY_STRING | cut -c1-2) VERSION=$(echo $QUERY_STRING | cut -c3-4) TYPE=$(echo $QUERY_STRING | cut -c5-6) CMD=$(echo $QUERY_STRING | cut -c7-8) REQUEST_ID=$(echo $QUERY_STRING | cut -c9-16 ) TIMEOUT=$(echo $QUERY_STRING | cut -c17-20 ) CONTENT_LENGTH=$(echo $QUERY_STRING | cut -c21-28 ) FUNCTION_ID=$(echo $QUERY_STRING | cut -c29-32) CONTENT=$(echo QUERY_STRING | cut -c33-((0x$CONTENT_LENGTH*2+28)))

    Convert TIMEOUT to decimal

    TIMEOUT_DEC=((0xTIMEOUT))

    Print fields

    printf "

    MAGIC: %s

    \n" "$MAGIC" printf "

    VERSION: %s

    \n" "$VERSION" printf "

    TYPE: %s

    \n" "$TYPE" printf "

    CMD: %s

    \n" "$CMD" printf "

    REQUEST_ID: %s

    \n" "$REQUEST_ID" #printf "

    TIMEOUT: %d

    \n" "$TIMEOUT_DEC" printf "

    TIMEOUT: %s

    \n" "$TIMEOUT" printf "

    CONTENT_LENGTH: %s

    \n" "$CONTENT_LENGTH" printf "

    FUNCTION_ID: %s

    \n" "$FUNCTION_ID" printf "

    CONTENT: %s

    \n" "$CONTENT"

    End HTML output

    printf "\n\n"

0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment