Skip to content

Instantly share code, notes, and snippets.

@genewoo
Forked from ryanmaclean/accept_xcode_license.sh
Created September 16, 2016 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save genewoo/de19830152ade70523aebd7ef1e9fc82 to your computer and use it in GitHub Desktop.
Save genewoo/de19830152ade70523aebd7ef1e9fc82 to your computer and use it in GitHub Desktop.
Accept Xcode License on the Command Line
# Run using "sudo accept_xcode_license.sh"
#
# Solving the OSX Yosemite Xcode Command Line Tools Licensing problem
# for multiple updates in order to script post-install tasks.
# Typical error reads after running "xcode-select --install" when setting up
# Homebrew is: "Agreeing to the Xcode/iOS license requires admin priviledges,
# please re-run as root via sudo"
#
# CREDIT:
# Based on a tip found at http://krypted.com/mac-os-x/licensing-the-xcode-command-line-tools/
# Also using the code found here: http://stackoverflow.com/questions/26125036
!/usr/bin/expect
set timeout 5
spawn sudo xcodebuild -license
expect {
"By typing 'agree' you are agreeing" {
send "agree\r\n"
}
"Software License Agreements Press 'space' for more, or 'q' to quit" {
send " ";
exp_continue;
}
timeout {
send_user "\nTimeout 2\n";
exit 1
}
}
expect {
timeout {
send_user "\nFailed\n";
exit 1
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment