kokoabim / iOSOpenDev-Installer

iOSOpenDev Installer
http://iOSOpenDev.com
Other
33 stars 20 forks source link

Automatic accept xcodebuild license #1

Closed tyilo closed 12 years ago

tyilo commented 12 years ago

This script will automatically accept the xcodebuild license. If it is not run as root it will show the sudo password prompt first.

#!/usr/bin/env expect -f
set timeout -1
spawn sudo xcodebuild -license

expect {
    "Password"
    {
        stty -echo
        expect_user -re "(.*)\n"
        stty echo
        set pass $expect_out(1,string)
        send -- "$pass\r"
        exp_continue
    }
    "incorrect password attempts"
    {
        exit 1
    }
    "Press 'space' for more"
    {
        send " "
        exp_continue
    }
    "By typing 'agree'"
    {
        send "agree\r"
        exp_continue
    }
}
thusithapk commented 12 years ago

Must have "Hit the Enter key to view the license agreements" expression as well. Otherwise this will not work if you run the script for the very first time.

#!/usr/bin/env expect -f
set timeout -1
spawn sudo xcodebuild -license

expect {
    "Password"
    {
        stty -echo
        expect_user -re "(.*)\n"
        stty echo
        set pass $expect_out(1,string)
        send -- "$pass\r"
        exp_continue
    }
    "incorrect password attempts"
    {
        exit 1
    }
    "Hit the Enter key to view the license agreements"
    {
        send "\r"
        exp_continue
    }
    "Press 'space' for more"
    {
        send " "
        exp_continue
    }
    "By typing 'agree'"
    {
        send "agree\r"
        exp_continue
    }
}
kokoabim commented 12 years ago

Nice script. But I myself do not want to provide a script that auto-accepts a license for another person. I leave it to the end-user to do so.

dimacus commented 10 years ago

this is very useful in case where i have a build farm with 100 macs and every time i upgrade xcode i do not wish to log into every one just to click on license, instead use my distro tool to push the xcode package and run this in post script to get a new machine up and running

sochoa commented 9 years ago

@thusithapk - Nice! Your version of the script made my life better. Thanks!

thusithapk commented 9 years ago

@sochoa

I give thanks to God. He is the only One who gives knowledge and understanding. Thank you Jesus!

With Xcode 5 onwards you don't need the old script. You just need this one liner.

# Accept Xcode 5+ License
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -license accept
cybertk commented 9 years ago

+1, for sudo xcodebuild -license accept