Connect to Wi-Fi via CLI / Script

If you ever got an error like „Error: -3924 Invalid PMK Failed to join network“ on OS X try to enclose the Wi-Fi Password in single quotes.

I use this script in a DeployStudio workflow for connecting to a default Wi-Fi Network without revealing the password to the user.


# Activate Wi-Fi on en1 and join SSID with password
	networksetup -setairportpower en1 on
	networksetup -setairportnetwork en1 SSID 'Password'
exit 0

Software Download on CLI through Proxy

If you work behind a proxy and want to download software from the command line on OS X you will run into troubles. Fortunately there are options for proxy configuration

(Follow up to my article Installing PEAR on OS X Lion)

Curl has its own option to set a proxy even with authentication

Excerpt from man page:

curl -x, --proxy <[protocol://][user@password]proxyhost[:port]>

Example for non-authenticated proxy:

curl --proxy > go-pear.php

If you work with the fabulous InstaDMG for creating OS X images for deployment you can set an environment variable in your shell like this:

for bash, sh and related shells

export HTTP_PROXY=

for csh and related shells


or just add it to your .profile