Agnus Dei (jackal) wrote,
Agnus Dei

best cgi ever. :) :) :)

The best CGI I've ever written.  :) :) :)

Basically it says take anything posted to this cgi and write it to a datafile with the timestamp (where I have other scripts come and process it).

In this case I'm just having one machine post json files to another (but I don't control the source machine).

This works because apache pipes all incoming data in as standard in, so you can cat it down to a file.  And I return a "Content-type: text/html\n\n" so the sending servers get a "200 OK" response code.

$ more /var/www/html/foo.cgi
TMPFILE=/opt/myproject/incoming/datafile.`/bin/date +%s%3N`  # Epoch time in milliseconds
cat > $TMPFILE ;  printf "Content-type: text/html\n\n"


  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened