2017-05-24 47 views
0

我使用Python 2.7 Paramiko SSH進入一個使用IBM 3151 keymapping的非常舊的系統。當時的鍵盤有一個用於提交響應的輸入或「發送」鍵。在Secure NetTerm中,我可以訪問此係統,「發送」鍵映射到鍵盤上的右側Ctrl鍵。在我的生活中,我無法弄清楚如何通過Paramiko將「發送」鍵發送到終端。以下是我的測試代碼。我能夠通過接受\ n的前幾個菜單選項來完成,但我正在進入一個需要「發送」鍵的「彈出」屏幕。按下右側的ctrl鍵在模擬器中工作,但我似乎無法得到任何東西在Paramiko工作。任何幫助,將不勝感激。Paramiko Emulating IBM 3151.我如何發送正確的控制按鍵

import paramiko 
import time 

ssh = paramiko.SSHClient() 
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) 
try: 
    ssh.connect('some_server.com', port=22,username='some_user', password='some_password') 
except paramiko.SSHException: 
    print "Connection Failed" 
    quit() 
channel = ssh.invoke_shell(term='IBM-3151', width=80, height=24, width_pixels=0, height_pixels=0) 
channel_data = str() 
host = str() 
srcfile = str() 

while True: 
    if channel.recv_ready(): 
     channel_data += channel.recv(9999) 
    else: 
     continue 
    print channel_data 
    #Go to store 
    if channel_data.endswith('> '):# in channel_data: 
     channel.send('5\n') 
     # Select a store 
    if channel_data.endswith(' : '): # in channel_data: 
     channel.send('0330\n') 
    if channel_data.endswith('): '): # in channel_data: 
     channel.send('Y\n') 
    if 'PRESS SEND TO CONTINUE....' in str(channel_data): 
     print 'test1' # if statement works 
     time.sleep(5) 
     channel.send('^[!l^M') # tried all kinds of stuff here 
     print 'test2' # script passes to here with no errors. 

回答

0

我會確定哪些字符實際上是由發送發送通過

  • 捕獲所有的字符(或輸入)鍵從使用script會話AIX系統(可能需要此分析)
  • 在AIX系統的shell中,使用cat (回聲)並按控制 -V按*前輸入

這樣做與工作終端當然。如果cat所示的數據不適用於您的腳本,則可能是已完成一些初始化,例如,將Secure NetTerm置於應用程序模式