Early in my learning how to write shell scripts, I decided to prank a coworker. I set a cron job to execute a script on his Mac to display an image via QuickLook. I randomized the time to help drive him nuts. He found it and deleted it immediately after the first execution because it wasn't nearly crafty enough.
Were I to do this today, I would use temporary dirs and such to obfuscate the location of the script, but whatever. I'm leaving in the raw info with my own debugging lines because that's where I was at the time (2007). Script follows:
#!/bin/bash
#roll to determine if the script continues. 0 is true, 1 is false
RANGE=2 number=$RANDOM let "number %= $RANGE"
roller=$number
echo $roller
#roll to determine if torture should begin
if (test $roller -eq 0) then echo roller is 0. we will torture.
RANGE=59
time=$RANDOM
let "time %= $RANGE"
echo $time minutes until we execute
#roll the delay before execution
gotime=$(expr $time "*" 60)
sleep $gotime
#copy the obscure file, rename it and open it
cp /bin/effu /tmp/pwned.jpg
open /tmp/pwned.jpg
else
echo roller is 1. no torture today.
fiAs an aside, I'm reminded of this classic prank: