defaults and extra space

I am working on forcing the Airport Menu into the Menu Bar for a script that I am writing and I have run into a strange error and would like to know if anyone knows a way around it. The error replicates in both Applescript and terminal.

If I execute defaults write menuExtras -array-add \ "/System/Library/CoreServices/Menu Extras/"
I get

. The leading space is throwing me and causing the menu to not show up.

I am on Snow Leopard 10.6.3.

Any suggestions?


What are you doing with that backslash after -array-add?

This also shows an extra space:

echo \ 'test'

Because the menu items are nested under MenuExtras I have to use the array-add option to add it. The "" starts the array items and if I take the space out then the “defaults” waits on another command (thus never completing).



why not

do shell script "open /System/Library/CoreServices/Menu\\ Extras/"

What do mean it “starts the array items”? It’s being interpreted by the shell as a space.

Works fine for me.

/usr/bin/defaults read menuExtras ( "/System/Library/CoreServices/Menu Extras/", "/System/Library/CoreServices/Menu Extras/", "/System/Library/CoreServices/Menu Extras/", "/System/Library/CoreServices/Menu Extras/", "/System/Library/CoreServices/Menu Extras/Script" ) /usr/bin/defaults write menuExtras -array-add \ "/System/Library/CoreServices/Menu Extras/" /usr/bin/defaults read menuExtras ( "/System/Library/CoreServices/Menu Extras/", "/System/Library/CoreServices/Menu Extras/", "/System/Library/CoreServices/Menu Extras/", "/System/Library/CoreServices/Menu Extras/", "/System/Library/CoreServices/Menu Extras/Script", " /System/Library/CoreServices/Menu Extras/" ) /usr/bin/defaults write menuExtras -array-add "/System/Library/CoreServices/Menu Extras/" /usr/bin/defaults read menuExtras( "/System/Library/CoreServices/Menu Extras/", "/System/Library/CoreServices/Menu Extras/", "/System/Library/CoreServices/Menu Extras/", "/System/Library/CoreServices/Menu Extras/", "/System/Library/CoreServices/Menu Extras/Script", " /System/Library/CoreServices/Menu Extras/", "/System/Library/CoreServices/Menu Extras/" )

Wow. Thanks to the both of you. Just opening the menu never crossed my mind. And Thanks Bruce, I now understand the array-add option a bit better.

Thanks to the always helpful MacScripter Forums.