Take Screenshot and Send It to Web Server

A previous post explained how to create a CUPS printer which sends it output as a bitmap images to a web server. This small script gives an example how to post screenshots to the same server backend. The script utilises scrot to take a screenshot and curl to send the image file to the server.


# Takes screenshot (using scrot) and transmit it to server via http (curl)


TEMPFILE=`/bin/tempfile --suffix=.jpeg`
echo "Temporary file: ${TEMPFILE}"

/usr/bin/scrot ${TEMPFILE}

/usr/bin/curl -i -F username=${USER} -F page0=@${TEMPFILE} ${URL}

if [ ${CURL_EXIT} -eq 0 ]; then
    zenity --info --text="Kuvan lähetys onnistui"
    zenity --error --text="Virhe kuvan lähettämisessä: ${CURL_EXIT}"


Leave a Reply

Your email address will not be published. Required fields are marked *