-3

I created a very simple bash script. The first line of the script after #!/bin/bash accesses my vpn service using an OPENVPN file provided by the VPN Vendor. It works as expected and then waits for data entry of my username and once entered expects my password.

I used the echo command to provide the required responses but they never occur. Open VPN just sits there waiting for my username. If I hit enter twice then OPENVPN terminates and my script completes by echoing the username and password.

#!/bin/bash
sudo openvpn /etc/openvpn/us-dtw.prod.xxxxxxx.com_udp.ovpn 
echo $'\r'
printf "                    xf3Z3ZY6xxxxxxxxEuRDmh"
echo $'\r'
echo "                      nvn7B5kxxxxhxxJstRU" 

What could be causing my script to hang and not execute the echo commands until OPENVPN terminates?

Maybe there is a way to pipe the text but I am really new to this.

Found an example that works correctly to automate the VPN logon process: https://help.anonine.com/support/solutions/articles/5000613671-how-do-i-save-my-username-password-in-openvpn-for-automatic-login-

  • Why make us guess about what in in your `bash` script? Please update your Q to include a sanitized (no personal information!) version of your script. Use the `{}` tool from the Edit menu on mouse-selected text to format as `code/data/requiredOutput/ExactErrMsgs`. Good luck. – shellter Sep 18 '20 at 02:44
  • When you put the `echo` line _after_ the `sudo openvpn` line, you're telling `echo` to run after `openvpn` exits. – Charles Duffy Sep 18 '20 at 12:25
  • Anyhow, openvpn has well-supported programmatic interfaces designed to be used for retrieving credentials (or, rather, multiple such interfaces -- one with a socket API, another in which it calls a named process, and probably more I'm forgetting). Don't hack something up yourself. – Charles Duffy Sep 18 '20 at 12:25

1 Answers1

0

openvpn will by default be using the TTY to get input, not standard input.

Have you looked at the --askpass option to openvpn?