I used pexpect
in windows for SSH. It didn't work. So I installed paramiko
. With paramiko
I'm able to login to the remote host .But I couldn't run the commands after 'conf' command. When I run the command 'set management cwmp enable on' it throws an error:
unrecognized command.
When run on putty
it will be like:
name:xyz
pass:xyz
>satus
#writes status
>magic
>UNLOCKED>
>UNLOCKED>conf
>>set management cwmp enable on
>>save
*configuration saved*
the above should appear.
Python code:
import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect( '192.168.2.254',port = 22, username = 'xyz', password = 'xyz')
stdin, stdout, stderr = ssh.exec_command( 'status' )
output = stdout.readlines()
print "\n".join(output)
stdin, stdout, stderr = ssh.exec_command('magic')
output1 = stdout.readlines()
print output1
stdin, stdout, stderr = ssh.exec_command('conf')
output1 = stdout.readlines()
print output1
stdin, stdout, stderr = ssh.exec_command('set management cwmp enable on')
output1 = stdout.readlines()
print output1
OUTPUT:
#after executing conf command
Unrecognized command
- I unable to find equivalent command like "'expect' in pexpect" in paramiko?