Posted on 07-05-2018 12:48 PM
I created a script to add to OD, but when I manually run, I get a message "Certificates are available for this server. Would you like to add them to the system keychain automatically (y/n)?"
The script will wait for a response. How can I automatically respond to this question in the script so it does not wait for a response?
Solved! Go to Solution.
Posted on 07-09-2018 08:37 AM
You might be able to use expect.
#!/bin/bash
# Some code here
/usr/bin/expect >/dev/null 2>&1 <<EOF
set timeout -1
spawn 'command that adds computer to OD without quotes'
expect "automatically (y/n)?"
send -- "y
"
expect eof
EOF
# Rest of code here
exit 0
Posted on 07-05-2018 02:08 PM
I hope this can help u:
Posted on 07-05-2018 03:02 PM
Yes and no, is there a way to just add a "y" to input into the pause?
Posted on 07-06-2018 10:42 AM
@salmon Create a package with the cert you want to install and put it on the local machine somewhere (tmp)
Read the last response in the thread for a hint as to how to install them after that (read them all for clarity though)
Posted on 07-06-2018 10:43 AM
Thank you, I did read it.
Posted on 07-06-2018 01:10 PM
@salmon My apologies, I misread your question as asking about acknowledging a GUI dialog prompt to the user. The approach @ryan.ball describes below should do what you want to acknowledge a (y/n) prompt in a bash script.
Posted on 07-09-2018 08:37 AM
You might be able to use expect.
#!/bin/bash
# Some code here
/usr/bin/expect >/dev/null 2>&1 <<EOF
set timeout -1
spawn 'command that adds computer to OD without quotes'
expect "automatically (y/n)?"
send -- "y
"
expect eof
EOF
# Rest of code here
exit 0
Posted on 07-09-2018 10:03 AM
Thank you, I will give that a try this morning!
Posted on 07-09-2018 10:41 AM
That worked perfectly for what I was doing! Thank you so much ryan.ball!