Python Paramiko模仿ibm3151。如何发送正确的控制按键

Python Paramiko模仿ibm3151。如何发送正确的控制按键,python,terminal,emulation,paramiko,Python,Terminal,Emulation,Paramiko,我正在使用Python2.7Paramiko将SSH连接到一个非常旧的系统中,该系统使用IBM3151KeyMapping。当时的键盘上有一个回车键或“发送”键用于提交响应。在Secure NetTerm中,我可以访问此系统,并且“发送”键映射到键盘上的右ctrl键。就我个人而言,我不知道如何用Paramiko将“send”键发送到终端。下面是我的测试代码。我能够通过前几个接受的菜单选项,但是我遇到了一个需要“发送”键的“弹出”屏幕。按右ctrl键在emulator中工作,但我似乎无法在Para

我正在使用Python2.7Paramiko将SSH连接到一个非常旧的系统中,该系统使用IBM3151KeyMapping。当时的键盘上有一个回车键或“发送”键用于提交响应。在Secure NetTerm中,我可以访问此系统,并且“发送”键映射到键盘上的右ctrl键。就我个人而言,我不知道如何用Paramiko将“send”键发送到终端。下面是我的测试代码。我能够通过前几个接受的菜单选项,但是我遇到了一个需要“发送”键的“弹出”屏幕。按右ctrl键在emulator中工作,但我似乎无法在Paramiko中获得任何工作。任何帮助都将不胜感激

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.

我将通过Send(或Enter)键确定实际发送的字符

  • 在AIX系统上使用
    script
    捕获会话中的所有字符(您可能需要它进行分析)
  • 在AIX系统上的shell中,使用
    cat
    (回显)并在按*Enter之前按control-V
当然可以用工作终端来做。如果
cat
显示的数据与您的脚本不兼容,则可能已完成一些初始化,例如,将Secure NetTerm置于应用程序模式