The pexpect pxssh do not create my requirement directory

39 Views Asked by At

I use the pexpect module to login a ssh server and then mkdir a directory:

from pexpect import pxssh

s = pxssh.pxssh()

s.login(server='43.24.24.29', username='root', password='my_password')

s.send('mkdir aaa')

s.logout()

it works, but I find, in the server, there created aaaexit directory, there is not aaa directory:

[root@localhost ~]# ls
aaaexit  anaconda-ks.cfg

I know there maybe the s.logout() affected it, but how to resolve this problem.

1

There are 1 best solutions below

0
aircraft On

You can use

s.send('mkdir aaa\n')

to avoid the issue.