#!/bin/bash #mail commands from remote machines > run here > mail its output #can even mail commands from windows/mobile to a remote linux :) #to use: #1. update next two vars #2. place this file in bin & run it #3. send a mail to your machine titled: run
#4. your machine will run it and mail you its output #5. when done, mail: run exit MAIL_URL=path-to-your-INBOX-folder MAIL=your@mail.com com="" clear echo "Listening to ${MAIL}" while : do #poll every 5 sec sleep 5 #get command from mail new_com=`cat $MAIL_URL | tail -9999 | grep 'Subject: run' | tail -1 | tr -d '\r'` new_com=${new_com:13} #Subject: run ls => ls #run only on-change if [ "$new_com" != "$com" ] then #exit command if [ "$new_com" = "exit" ]; then exit; fi #run command & mail it com=$new_com echo $com output=`$com` echo "$output" #echo "$output" | mailx -s "${com}" ${MAIL} fi done