#!/bin/bash # you'll get 3 emails from this date=$(date +%Y.%m.%d.%H.%M.%s) echo "select which window to send" /usr/bin/scrot -s /tmp/${date}.png result=$(/home/user/script/send.to.somehost.com.sh /tmp/${date}.png ${date}.png week) ssh "somehost.com" "echo ${result} | mail -es 'scrot ${date}' 'scrot@somehost.com'" rm /tmp/${date}.png