免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1099 | 回复: 0
打印 上一主题 下一主题

求助:为什么subprocess发送ascsii码7不能进入erlang shelll的JCL模式 [复制链接]

论坛徽章:
2
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:57:09
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2014-09-14 20:08 |只看该作者 |倒序浏览
我这边要写个python和erlang shell互交的的脚本,查了下ctrl+g就是ascii码7
我直接发送ascii码7好像没法进入jcl模式

python 脚本如下,两个h命令是测试输出的
def erl_shell(user_name):
    global ipaddr
    random_sname = 'random_etsinfo' + str(int(random.uniform(1000, 2000)))
    command = "erl -name %s@%s -setcookie loginserver_%s" % (random_sname,ipaddr,user_name)
    print command

    print 'start temp erl process'
    child = subprocess.Popen(command, stdin = subprocess.PIPE,
                         stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True)
    time.sleep(3)
    out_put = child.stdout.readline()
    print 'out put start erl command return [%s]' % out_put
    time.sleep(1)

    print 'send command h to tmp erl process'
    command = chr(ord('h'))
    print command
    child.stdin.write(command + '.\r\n')
    time.sleep(1)
    out_put = child.stdout.readline()
    print 'out put h command return %s' % out_put

    print 'send command ctrl+g to tmp erl process'
    command = chr(7)
    child.stdin.write(command)
    #child.stdin.write(command + '\r\n')
    child.stdin.flush()
    time.sleep(1)
    out_put = child.stdout.readline()
    child.stdout.flush()
    print 'out put ctrl+g command return [%s]' % out_put
    time.sleep(1)

    print 'send command h to tmp erl process'
    command = chr(ord('h'))
    print command
    child.stdin.write(command + '.\r\n')
    time.sleep(1)
    out_put = child.stdout.readline()
    print 'out put h command return %s' % out_put

    print 'send command r to tmp erl process'
    command = "r 'loginserver_%s@%s'" % (user_name, ipaddr)
    child.stdin.write(command + '\r\n')
    time.sleep(1)
    out_put = child.stdout.readline()


互相交结果如下
erl -name random_etsinfo1352@127.0.0.1 -setcookie loginserver_s1
start temp erl process
out put start erl command return [Eshell V5.9.3  (abort with ^G)
]
send command h to tmp erl process
h
out put h command return (random_etsinfo1352@127.0.0.1)1> h

send command ctrl+g to tmp erl process
out put ctrl+g command return [(random_etsinfo1352@127.0.0.1)2> Eshell V5.9.3  (abort with ^G)
]
send command h to tmp erl process
h
out put h command return (random_etsinfo1352@127.0.0.1)1> h

send command r to tmp erl process
然后就卡在这了

两个命令结果可以看出来没进入到jcl模式.....难道我字符发错了?ctrl+g要发送啥?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP