-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJoinDomain.exp
More file actions
30 lines (20 loc) · 765 Bytes
/
JoinDomain.exp
File metadata and controls
30 lines (20 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/expect
set timeout 10
set domain [lindex $argv 0]
set username [lindex $argv 1]
set password [lindex $argv 2]
if {[llength $argv] == 0} {
send_user "Usage: JoinDomain.exp 'domain' 'username' 'password'\n"
exit 1
}
spawn realm join --user=$username@$domain $domain
expect {
timeout { send_user "\nFailed to get the password prompt\n"; exit 1}
eof { send_user "\nFailed to join to the domain $domain with username $username and password $password\n"}
"*assword" { send "$password\r"}
}
expect {
timeout { send_user "Didn't get a response within the timeout period after putting in the password"; exit 1}
"Couldn't join realm" { send_user "Failed to join to the domain\n"; exit 1}
}
send_user "Successfully joined to the domain\n"