Last active
August 29, 2015 14:15
-
-
Save tjluoma/1aa06ec2377a96c73c37 to your computer and use it in GitHub Desktop.
I use this script to send myself iMessages from my server at www.MacMiniColo.net when I need to know something (i.e. backup completed, diskspace getting low, etc). I got the idea from http://www.tenshu.net/2015/02/send-imessage-and-sms-with-applescript.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/zsh -f | |
| ### Change this to be your iMessage email account | |
| MY_IMESSAGE='[email protected]' | |
| ### You should not need to change anything else | |
| ### I suggest saving this to /usr/local/bin/imsg.sh | |
| ### then `chmod 755 /usr/local/bin/imsg.sh` | |
| ################################################################################################### | |
| # This is the name of the script without the path or the extension, so 'imsg' if you | |
| # use the name I've recommended | |
| SCRIPT_NAME="$0:t:r" | |
| if [ "$#" = "0" ] | |
| then | |
| echo "Usage: $NAME message that you want to send" | |
| exit 1 | |
| fi | |
| # This is whatever input you've given to the script | |
| MSG="$@" | |
| # Here's where we send it | |
| /usr/bin/osascript <<EOT | |
| tell application "Messages" | |
| send "${MSG} [via $SCRIPT_NAME]" to buddy "$MY_IMESSAGE" of (service 1 whose service type is iMessage) | |
| end tell | |
| EOT | |
| exit 0 | |
| # | |
| # Purpose: Send iMessages from to myself from the command line. | |
| # Adapted from: http://www.tenshu.net/2015/02/send-imessage-and-sms-with-applescript.html | |
| # | |
| # From: Tj Luo.ma | |
| # Mail: luomat at gmail dot com | |
| # Web: http://RhymesWithDiploma.com | |
| # Date: 2015-02-21 | |
| # | |
| #EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment