I'm a newbie to write bash script,I was using macOS catalina, and
I write a bash script which use expect to run openconnect,
#!/usr/bin/expect...spawn sudo openconnect --user xxx --protocol=anyconnect...send xxxinteract
this works perfectly,but I want to run it in background, when I add '-b'(or --background parameter),
#!/usr/bin/expect...spawn sudo openconnect --user xxx --protocol=anyconnect -b...send xxxinteract
the output shows the pid is running in background, but the pid is not exit actually, and the connect isn't successful,
Is there anything I'm missing or I did incorrect?
EDIT: If I do not use this script, just using openconnect -b directly in terminal,it works, but I want to use expect so I can connect use script to connect automatically