I have a bunch of Mac computers that have just updated Xcode and must accept the EULA. I am trying to do this through a script.
set timeout 15
spawn sudo xcodebuild -license
expect {
"*License.rtf'\n" { # Press Enter to view agreement
send "\r"
}
timeout {
send_user "\nFailed\n";
exit 1
}
}
expect {
"Software License Agreements Press 'space' for more, or 'q' for quit" {
send_user " ";
exp_continue;
}
"By typing 'agree' you are agreeing" {
send_user "agree\r"
}
timeout {
send_user "\nTimeout 2\n";
exit 1
}
}
However, it never gets the first wait (that is, it never sends "\ r" to 'Enter'. Here is the result:
$ ./test.sh
spawn sudo xcodebuild -license
You have not agreed to the Xcode license agreements. You must agree to both license agreements below in order to use Xcode.
Hit the Enter key to view the license agreements at '/Applications/Xcode.app/Contents/Resources/English.lproj/License.rtf'
Failed
EDIT: The script has been updated as follows, now the wait time comes in the second wait:
set timeout 15
spawn sudo xcodebuild -license
expect {
"*License.rtf" {
send "\r"
}
timeout {
send_user "\nFailed\n";
exit 1
}
}
expect {
"By typing 'agree' you are agreeing" {
send "agree\r"
}
"*Press 'space' for more, or 'q' for quit" {
send " ";
exp_continue;
}
timeout {
send_user "\nTimeout 2\n";
exit 1
}
}
Chris source
share