I'm trying to run a simple code from applescript.
It use blueutil, a command-line utility that can query Bluetooth’s status (on or off) / turn it on / turn it off.
I try this code from rob cottingham:
tell application “Terminal”
do shell script “/usr/local/bin/blueutil status”
set _Result tothe result
if _Result is “Status: on” then
do shell script “/usr/local/bin/blueutil off”
endif
if _Result is “Status: off” then
do shell script “/usr/local/bin/blueutil on”
endif
endtell
Without success. If i clean all and only keep the lines about turning off or on, it works though.
Cleanest code I seems to get is:
tell application "Terminal"
do shell script "/usr/local/bin/blueutil status"
set theResult to the result
if "result" is "Status: on" then
do shell script "/usr/local/bin/blueutil off"
end if
end tell
But still doesn't work.
Maybe it's about using the result of the query as a variable?
I'm really not a professional it as you probably guessed, so any help will be appreciated ! Thanks, Christophe.
set theResult to do shell script "/usr/local/bin/blueutil status". However, I've tried to executeblueutil statusin my terminal and apparently the argument Status doesn't exist.do shell script.blueutil -p.