is there a way to run a process when connected to a certain device?

is there a way to run a process when connected to a certain device?
I was looking for a command line option and every chat lead back to this:
http://bluetoothinstaller.com/bluetooth-command-line-tools/
Imagine it will be along the lines of:
Run command line
Read command Prompt
Parse & Get SubText from command prompt Text
If SubText = [whatever], then continue flow.
Good luck!