How to fix "Invalid argument" of pexpect send/sendline on windows with python?

92 views Asked by At

On windows 10 I am using the following python code to send a command to a device

import pexpect
from pexpect import popen_spawn
session = popen_spawn.PopenSpawn(f"plink.exe -ssh 192.168.200.10 9000")
session.expect(pexpect.EOF, timeout=2)
session.send("$SYS,INFO\r\n")
time.sleep(5)
print(session.read_nonblocking(4096, 1))

But all I get is an error

OSError: [Errno 22] Invalid argument

I tried to encode the string, use sendline instead, with and without the \r\n, but always the same error. Anything I am missing here?

  • windows 10
  • python 3.10.11
  • pexpect 4.8.0
0

There are 0 answers