免费注册 查看新帖 |

Chinaunix

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

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

论坛徽章:
2
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:57:09
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2014-09-14 17:24 |只看该作者 |倒序浏览
本帖最后由 lolizeppelin 于 2014-09-14 17:26 编辑

我这边要写个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要发送啥?

论坛徽章:
27
水瓶座
日期:2014-08-22 21:06:34程序设计版块每日发帖之星
日期:2015-11-25 06:20:0015-16赛季CBA联赛之新疆
日期:2015-12-19 19:05:48IT运维版块每日发帖之星
日期:2015-12-25 06:20:31IT运维版块每日发帖之星
日期:2015-12-25 06:20:31IT运维版块每日发帖之星
日期:2015-12-25 06:20:3315-16赛季CBA联赛之上海
日期:2016-04-15 19:51:31程序设计版块每日发帖之星
日期:2016-04-17 06:23:29程序设计版块每日发帖之星
日期:2016-04-23 06:20:00程序设计版块每日发帖之星
日期:2016-05-26 06:20:00每日论坛发贴之星
日期:2016-05-26 06:20:0015-16赛季CBA联赛之辽宁
日期:2017-02-16 23:59:47
2 [报告]
发表于 2014-09-14 20:25 |只看该作者

h是什么啊,返回也不对吧

论坛徽章:
2
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:57:09
3 [报告]
发表于 2014-09-14 21:34 |只看该作者
本帖最后由 lolizeppelin 于 2014-09-14 21:36 编辑

没有h这个命令
h.会打印出h 这个字符串而已

我只是在发送ctrl+g之前和都打印了h来确认没有进入jcl模式

论坛徽章:
2
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:57:09
4 [报告]
发表于 2014-09-15 20:31 |只看该作者
5555 没人回复么~~
ctrl+g我查询了stty也没有表示ctrl+g是什么信号.....
但是发ascii码也不对啊 ......有没看过 erlang源代码的~
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP