sending notifications with iMessage via osascript

Come up with a useful post-processing script? Share it here!
Post Reply
Chanch
Newbie
Newbie
Posts: 5
Joined: July 25th, 2011, 8:22 pm

sending notifications with iMessage via osascript

Post by Chanch »

I am trying to send imessage notifications from a Sab post-processing script. I've tried a few things so far:
This script works from the command line

Code: Select all

#!/bin/bash
#sends message via Messages to BUDDY
#[email protected]
osascript -e 'on run argv' -e 'tell application "iChat"' -e 'set theMessage to argv' -e 'send theMessage to buddy "[email protected]" of service 1' -e 'end tell' -e 'end run' "$*"
then I changed it a little for Sab, but if "$3" ,the clean file name, has spaces in the name it only sent the 1st item. (I assumed that was because of the "item 1 of argv" in the applescript part)

Code: Select all

#!/bin/bash
#sends message via Messages to BUDDY
#[email protected]
osascript -e 'on run argv' -e 'tell application "iChat"' -e 'set theMessage to item 1 of argv' -e 'send theMessage to buddy "[email protected]" of service 1' -e 'end tell' -e 'end run' "Your Show has finished downloading "$3""
so I tried taking out the "item 1 of argv" , but now I get this error in sab
60:119: execution error: iChat got an error: Can’t make {"Your Show has finished downloading Too", "Big", "To", "Fail", "2011", "DVDRip", "XviD", "BeStDivX"} into type text, file, constant. (-1700)
any ideas? Thanks
User avatar
sander
Release Testers
Release Testers
Posts: 8832
Joined: January 22nd, 2008, 2:22 pm

Re: sending notifications with iMessage via osascript

Post by sander »

Change "$3" into \"$3\" ?
Play with IFS?
Put $3 only after the -e ?
Google "bash spaces in variables"?

I have no osascript so I can't test it for you.

I hate bash because of these problems. I would put it in python script ... problem solved.
Chanch
Newbie
Newbie
Posts: 5
Joined: July 25th, 2011, 8:22 pm

Re: sending notifications with iMessage via osascript

Post by Chanch »

Thanks Sander, I just got to work. I'll try your suggestions when I get home. Escaping the quotes seems like it might work to me. Youre right Ive been slacking on learning python though. I need to set some time aside for that
Chanch
Newbie
Newbie
Posts: 5
Joined: July 25th, 2011, 8:22 pm

Re: sending notifications with iMessage via osascript

Post by Chanch »

This works:

Code: Select all

osascript -e 'on run argv' -e 'tell application "iChat"' -e 'set theMessage to item 1 of argv' -e 'send theMessage to buddy "[email protected]" of service 1' -e 'end tell' -e 'end run' "Your Show has finished downloading: ""$3"
I double quoted the message "Your Show has finished downloading: " and the "$3" separately.
Post Reply