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 com.apple.systemuiserver menuExtras -array-add \ "/System/Library/CoreServices/Menu Extras/AirPort.menu"
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?

dp

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).

dp

Hi,

why not

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

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 com.apple.systemuiserver menuExtras ( "/System/Library/CoreServices/Menu Extras/TimeMachine.menu", "/System/Library/CoreServices/Menu Extras/AirPort.menu", "/System/Library/CoreServices/Menu Extras/Battery.menu", "/System/Library/CoreServices/Menu Extras/Clock.menu", "/System/Library/CoreServices/Menu Extras/Script Menu.menu" ) /usr/bin/defaults write com.apple.systemuiserver menuExtras -array-add \ "/System/Library/CoreServices/Menu Extras/AirPort.menu" /usr/bin/defaults read com.apple.systemuiserver menuExtras ( "/System/Library/CoreServices/Menu Extras/TimeMachine.menu", "/System/Library/CoreServices/Menu Extras/AirPort.menu", "/System/Library/CoreServices/Menu Extras/Battery.menu", "/System/Library/CoreServices/Menu Extras/Clock.menu", "/System/Library/CoreServices/Menu Extras/Script Menu.menu", " /System/Library/CoreServices/Menu Extras/AirPort.menu" ) /usr/bin/defaults write com.apple.systemuiserver menuExtras -array-add "/System/Library/CoreServices/Menu Extras/AirPort.menu" /usr/bin/defaults read com.apple.systemuiserver menuExtras( "/System/Library/CoreServices/Menu Extras/TimeMachine.menu", "/System/Library/CoreServices/Menu Extras/AirPort.menu", "/System/Library/CoreServices/Menu Extras/Battery.menu", "/System/Library/CoreServices/Menu Extras/Clock.menu", "/System/Library/CoreServices/Menu Extras/Script Menu.menu", " /System/Library/CoreServices/Menu Extras/AirPort.menu", "/System/Library/CoreServices/Menu Extras/AirPort.menu" )

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.

dp