1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Python NetExtender CLI

Discussão em 'Python' iniciado por Stack, Julho 3, 2025.

  1. Stack

    Stack Membro Participativo

    I'm attempting to build a script that I can use to connect to my SonicWall NetExtender VPN via Python.

    Currently my connect method successfully triggers the OTP password to be sent to my email.

    def connect(self, server, username, password, domain):
    # Define the command to run the VPN connection
    command = f'"{self.necli_path}" connect -s {server} -u {username} -p {password} -d {domain}'

    # Start the process
    self.process = subprocess.Popen(
    command,
    stdin=subprocess.PIPE,
    stdout=subprocess.PIPE,
    stderr=subprocess.PIPE,
    shell=True,
    text=True
    )


    but when I try to simulate the entering of the OTP in my submit_otp method, nothing happens:

    def submit_otp(self, otp):
    if self.process is None:
    return False, "Error: The VPN process has not been initialized."

    # Check if process.stdin is still open
    if self.process.stdin.closed:
    return False, "Error: The process stdin stream has been closed."

    # Send the OTP after VPN prompts for it
    otp_command = otp + "\n" # Simulate pressing "Enter" after OTP
    self.process.stdin.write(otp_command)
    self.process.stdin.flush()

    return True, None


    Any help is greatly appreciated, TiA!

    Continue reading...

Compartilhe esta Página