I wrote this script for an vpn connection.
Now i want to check if the output which is stored in $vpn
contains "Authentication failed".
If it contains then it should exec. the script again.
There is no error, it just shows me nothing when i type the password not correct. The output of the vpn connection when i connect with a wrong password looks like this:
POST https://vpn.domain.de/
Verbunden mit XX.XX.XXX.XXX:443
SSL-Verhandlung mit vpn.domain.de
Verbunden mit HTTPS auf vpn.domain.de
Server forderte ein SSL Client-Zertifikat an. Es ist keines eingerichtet
POST https://vpn.domain.de/
XML POST aktiviert
POST https://vpn.domain.de/
Server forderte ein SSL Client-Zertifikat an. Es ist keines eingerichtet
POST https://vpn.domain.de/
XML POST aktiviert
POST https://vpn.domain.de/
**Authentication failed.**
Username:fgets (stdin): Die Ressource ist zur Zeit nicht verfügbar
Can somebody pls. tell me where my mistake is?
#!/bin/bash
echo Bitte Passwort eingeben:
read x
if [ -z "$x" ]
then
echo "Kein Passwort eingegeben!!!"
echo "Bitte erneut versuchen"
exec "/home/ubuntu/Dokumente/vpn.sh"
else
vpn=(echo $x |
sudo openconnect vpn.domain.de --user=test.vpn --passwd-on-stdin --authgroup vpn-client-no-ise --no-dtls)
fi
if [[ $vpn == *"Authentication failed"* ]]; then
echo "Dein Passwort war falsch!"
exec "/home/ubuntu/Dokumente/vpn.sh"
fi
read