Skip to main content
Question

How to script Unix Executable that requires input?


Forum|alt.badge.img+6

I have a uninstaller that is a Unix executable but it prompts for confirmation.

Do you wish to continue (yes/no)?

So when I have a script call the executable it just hangs forever, how can I script it so the uninstaller runs correctly?

I've tried

sudo "./Uninstall -Yes"

and

sudo "./Uninstall -Y"

No luck. any advice would be appreciated.

3 replies

Forum|alt.badge.img+9
  • Contributor
  • 154 replies
  • June 11, 2020

Hi @djrory ,
You could try:

#Respond to Yes or No prompt with a sleep time of 5 seconds
(sleep 5; printf "Yes") | "/path/to/uninstaller"

Not sure if this is the same program, but is there a uninstall.sh, that'd probably be your best bet

sudo "/Library/Application Support/Checkpoint/Endpoint Security/uninstall.sh"

Forum|alt.badge.img+6
  • Author
  • Contributor
  • 73 replies
  • June 11, 2020

@shaquir I found that out just after I posted this, Uninstaller seems to just call the uninstall script with the line

sudo "./uninstall" --uninstall

So I put that in the script and it worked.

Thanks for the response though, always handy to know!


wmehilos
Forum|alt.badge.img+11
  • Valued Contributor
  • 69 replies
  • June 11, 2020

It's something I've never needed to really write myself, but I believe expect might be a solution for what you need. It used to be needed when accepting the Xcode license automagically with a script, since xcodebuild used to require someone enter "accept" into the Terminal window.

You'd want something like this as a script body:

/usr/bin/expect -f

set timeout -1

spawn ./path/to/your/interactive/script.sh

expect "Do you wish to continue (yes/no)"

send "yes
"

expect eof

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings