Sending/Routing all Recieved iChat messages to the Shell

Hello,

I have a script that I have working that can send messages from the shell to iChat based on this script here:

http://frefo.blogspot.com/2008/07/replacement-script-for-zwrite-using.html

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!
mark

Model: G5
Browser: Firefox 3.0.10
Operating System: Mac OS X (10.5)

Hi,

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"

I get:

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

YES!!!

That backslash / forward-slash thing was my problem!!! Thanks a ton!! Works great now!!

Best
mark