From fbd0c39073641cc1fe44d1a26b325f75f679aa7f Mon Sep 17 00:00:00 2001 From: Miguel Nogueira Date: Wed, 12 Jun 2019 16:36:22 +0200 Subject: [PATCH] Modify to expect end of file upon script completion --- pyvpn | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pyvpn b/pyvpn index 8cd426f..532317f 100755 --- a/pyvpn +++ b/pyvpn @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import os +import time import sys import pexpect import os.path @@ -24,13 +25,12 @@ if len(sys.argv) > 2: configFilePath = operatingDir + "/" + clientName + ".ovpn" - fScript.expect(".*[1-4]:") + fScript.expect("Looks") fScript.sendline("1") - fScript.expect(".*name:") + fScript.expect("Tell") fScript.sendline(clientName) - fScript.expect(".*") + fScript.expect(pexpect.EOF) - fScript.kill(0) if os.path.exists(configFilePath): @@ -40,21 +40,21 @@ if len(sys.argv) > 2: sys.stdout.write(finalResult) sys.stdout.flush() - sys.exit() + quit() else: sys.stdout.write("Error! OpenVPN did not create the Configuration file.") sys.stdout.flush() - sys.stdout.exit() + quit() else: sys.stdout.write("Error! Missing options!") sys.stdout.flush() - sys.stdout.exit() + quit() else: sys.stdout.write("Error! Missing client name!") sys.stdout.flush() - sys.stdout.exit() + quit()