Skip to content

Commit

Permalink
Update zcli-login.expect
Browse files Browse the repository at this point in the history
  • Loading branch information
nahbee10 authored Dec 18, 2024
1 parent b13d725 commit 211a8d1
Showing 1 changed file with 38 additions and 8 deletions.
46 changes: 38 additions & 8 deletions bin/zcli-login.expect
Original file line number Diff line number Diff line change
@@ -1,18 +1,48 @@
#!/usr/bin/expect -f

# Set an unlimited timeout
set timeout -1

# Define environment variables
# Capture arguments
set subdomain [lindex $argv 0]
set email [lindex $argv 1]
set token [lindex $argv 2]

# Run zcli login
# Spawn the zcli login command
spawn zcli login -i
expect "Subdomain:"
send "$subdomain\r"
expect "Email:"
send "$email\r"
expect "API Token:"
send "$token\r"

# Handle Subdomain prompt
expect {
"Subdomain:" {
send "$subdomain\r"
}
timeout {
puts "Error: Timeout while waiting for 'Subdomain:' prompt"
exit 1
}
}

# Handle Email prompt
expect {
"Email:" {
send "$email\r"
}
timeout {
puts "Error: Timeout while waiting for 'Email:' prompt"
exit 1
}
}

# Handle API Token prompt
expect {
"API Token:" {
send "$token\r"
}
timeout {
puts "Error: Timeout while waiting for 'API Token:' prompt"
exit 1
}
}

# Wait for the process to complete
expect eof

0 comments on commit 211a8d1

Please sign in to comment.