tonsky / AnyBar

OS X menubar status indicator
Eclipse Public License 1.0
5.92k stars 159 forks source link

How do I specify udp port with applescript? #61

Open moshed opened 7 years ago

moshed commented 7 years ago

i know in shell i can do echo -n black | nc -4u -w0 localhost <port number> but i cant figure out how to accomplish this in applescript (besides using do shell script "command")

http://imgur.com/a/tlRXc

this would suggest its possible to set the udp port but i cant figure out the syntax.

tonsky commented 7 years ago

AppleScript API doesn’t work through UDP. It issues commands directly (through Apple APIs? I’m not an expert in those). So the way it should work for you must be to find an instance with the port you need and issue command to that specific instance

On Tue, Dec 6, 2016 at 3:02 AM moshed notifications@github.com wrote:

i know in shell i can do echo -n black | nc -4u -w0 localhost <port number> but i can figure out how to accomplish this in applescript.

http://imgur.com/a/tlRXc

this would suggest its possible to set the udp port but i cant figure out the syntax.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/tonsky/AnyBar/issues/61, or mute the thread https://github.com/notifications/unsubscribe-auth/AARabHP-dfnjYgZVynXLRLYM-O4qaWnlks5rFG1igaJpZM4LEpgc .

moshed commented 7 years ago

hmm ok ill try and report my results here thanks!

npazo commented 7 years ago

I found that doing do shell script doesn't work as you would expect. Because the echo it uses by default doesn't support -n. Therefore I had to provide the full path to echo. Thus my AppleScript line became:

do shell script "/bin/echo -n 'blue' | nc -4u -w0 localhost 1738"

Might want to add to the README for anyone else that tries to do this.

moshed commented 7 years ago

yeah i arrived at same conclusion @npazo did.