So i have this script to create a user in my openvpn the create_user.sh is working fine. but i want to create a bulk user for my openvpn and when i run this expect script it's also working fine its response exactly to the prompt of the openvpn easyrsa. but the problem comes if I test the user and try to connect to openvpn it gives me error.
#!/usr/bin/expect
set user [lindex $argv 0]
set pass1 [lindex $argv 1]
set pass2 [lindex $argv 2]
set phrase [lindex $argv 3]
set timeout -1
spawn ./create_user.sh
expect "Enter Username:" { send -- "$user\r" }
expect "Enter PEM pass phrase:" { send -- "$pass1\r" }
expect "Verifying - Enter PEM pass phrase:" { send -- "$pass2\r"}
expect "Enter pass phrase for /etc/openvpn/pki/private/ca.key:" { send -- "$phrase\r"}
expect eof
I know that the problem is in my PEM pass and pass phrase but when I use my create_user.sh its working fine and it can connect to the openvpn server. so I guess my expect script is not working fine when passing the values to the prompt of PEM pass phrase and pass phrase. can somebody help me on this I'm just newbie in expect scripting.
This is the prompt when the create_user.sh run. enter image description here