A script to send notes to a Bluetooth phone

Apr 16, '04 09:39:00AM

Contributed by: Anonymous

I recently got a Sony Ericsson T616 phone. It works perfectly with iSync. However, I like to be able to send notes to the phone, but iSync does not support it. To send a note to the phone, one can use BlueNotes to create a .vnt file then send through Bluetooth File Exchange (in Applications -> Utilities). This is a little bit tedious, so I create a python script, sendNote.py, to send a note directly from a terminal. This is the script:

#!/usr/bin/env /usr/bin/python
import sys,os

msg = ""
for l in sys.stdin.readlines():
  msg += l.strip()
  msg += " / "

homePath = os.environ["HOME"]

tmpf = open("%s/.BTNote.vnt" % homePath,"w")
if len(msg) < 250:
  msg = msg[:250]
else:
  msg = msg[:-3]
tmpf.write("BEGIN:VNOTEnVERSION:1.1nBODY:%snEND:VNOTE" % msg[:-3])
tmpf.close()

# Enter the next two lines as one long line, no spaces...
os.system("/usr/bin/open -a /Applications/Utilities/
 Bluetooth File Exchange.app %s" % tmpf.name)
Usage:
$ cat | python sendNote.py
My test note
You should use the Control-D keystroke at the end of the note you want to send. In the above example, a note with content "My test note" will be sent to the device you choose in Bluetooth File Exchange. It is also possible to wrap the script with a simple GUI. I wrote a simple application called BNSend.app to send notes through Bluetooth to my phone. The source code is included. My implementation depends on the open command and the python script, because I could not find a way to communicate with Bluetooth File Exchange via AppleScript. I would like to know if there is any way to talk to Bluetooth File Exchange with only AppleScript.

Comments (9)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20040413031046870