- 论坛徽章:
- 2
|
我这边要写个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要发送啥? |
|