Modify to expect end of file upon script completion

This commit is contained in:
Miguel Nogueira 2019-06-12 16:36:22 +02:00
parent 22ad235cd1
commit fbd0c39073
1 changed files with 8 additions and 8 deletions

16
pyvpn
View File

@ -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()