Particle-CLI scripts/automation for initial setup on large number of devices

Here’s an expect script using a *nix command line (note: not the Particle CLI, just plain old Bash or whatever):

#!/usr/bin/expect -f

# SSID:
# Security 0=unsecured, 1=WEP, 2=WPA, 3=WPA2:
# Wifi Password:

eval spawn particle serial wifi

expect "Should I scan for nearby Wi-Fi networks?"
send "n\r"
sleep 0.1

expect "SSID:"
send "YourSecureWirelessNetwork\r"
sleep 0.1

expect "WPA2"
send "\r"
sleep 0.1

expect "Wi-Fi Password:"
send "YourAwesomePassword\r"

interact

As long as it’s a WPA2 network, you should be okay. And keep the \r at the end of the lines.