I have a script that I have working that can send messages from the shell to iChat based on this script here:
I am looking for a way though to send all received messages in iChat to the shell - the opposite of this script. If anyone has an example that would help me or point me in the right direction that would be great!
Ultimately I want to route all messages received to another program run from the shell that I would do something like:
echo $MESSAGE | pdsend 1571
Thanks for any help supplied!
Browser: Firefox 3.0.10
Operating System: Mac OS X (10.5)
I havent tested it, but this event handler could do it
using terms from application "iChat"
on message received themessage from theBuddy for theChat
do shell script "/bin/echo " & quoted form of themessage
end message received
end using terms from
save the script in ~/Library/Scripts/iChat/ and connect the appropriated buddies via the Message Received alert to the script
Oh this is wonderful and very helpful!! I am getting closer…
So I am not really sure I need “quoted form of”?
…but I am wondering because my shell script is for example:
which works fine… but when i try in applescript for example:
do shell script "echo " & theMessage & " /; | pdsend 1570"
An error occurred while executing an AppleScript event handler.
Event: Message Received
Error: sh: -c: line 0: syntax error near unexpected token
|' sh: -c: line 0: echo hello world /; | pdsend 1570’
Could I be doing something wrong then?
in your shell line there’s a backslash, in the AppleScript line a slash.
A backslash must be escaped with a second backslash
do shell script "echo " & theMessage & " \\; | pdsend 1570"
You will need
quoted form of to avoid errors, if the message contains space or other special characters
That backslash / forward-slash thing was my problem!!! Thanks a ton!! Works great now!!