2017-04-19 6 views
0

Paramikoからsshを使用してCisco UCSMに接続しようとしています。私の命令は失敗に終わっています。同じコマンドを手動で入力するとうまくいきます。どうか問題を解決する方法を教えてください。Paramiko for SSH cisco UCSMが失敗する

コード:

import time 
import paramiko 
import getpass 
host = "10.10.10.10" 
username = "admin" 
password = getpass.getpass("Please enter Password:") 
c=paramiko.SSHClient() 
c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) 
c.connect(host,username=username,password=password) 
print "connection to %s established" %host 
time.sleep(1) 
stdin, stdout, stderr = c.exec_command("scope org db") 
output = stdout.read() 
print output 
time.sleep(2) 
stdin, stdout, stderr = c.exec_command('show service-profile') 
output = stdout.read() 
print output 

出力:

Please enter Password: 
    connection to 10.10.10.10 established 

            ^
    % Incomplete Command at '^' marker 

手動でUCSMでコマンドを入力する:

ucsm1# scope org db 
ucsm1 /org # show service-profile 

Service Profile: 
Service Profile Name Type    Server Assignment Association 
-------------------- ----------------- ------- ---------- ----------- 
db/SP-DB1 
        Instance   8/7  Assigned Associated 

ucsm1 /org # 

おかげで、

答えて

1

よりもむしろexec_commandは、あなたが試すことができます:

remote_conn = remote_conn_pre.invoke_shell() 
output = remote_conn.recv(65535) 
remote_conn.send('scope org db\n') 
関連する問題