diff --git a/ruby_pybridge/hola.rb b/ruby_pybridge/hola.rb new file mode 100644 index 0000000..39bf01b --- /dev/null +++ b/ruby_pybridge/hola.rb @@ -0,0 +1,10 @@ +while cmd = STDIN.gets + cmd.chop! + if cmd == "exit" + break + else + print eval(cmd),"\n" + print "[end]\n" + STDOUT.flush + end +end diff --git a/ruby_pybridge/holaback.py b/ruby_pybridge/holaback.py new file mode 100644 index 0000000..ca6dea4 --- /dev/null +++ b/ruby_pybridge/holaback.py @@ -0,0 +1,19 @@ +from subprocess import Popen, PIPE, STDOUT + +print 'launching hola process...' +hola = Popen(['ruby', 'hola.rb'], stdin=PIPE, stdout=PIPE, stderr=STDOUT) + +while True: + line = raw_input('Enter expression or exit:') + hola.stdin.write(line+'\n') + result = [] + while True: + if hola.poll() is not None: + print 'hola has terminated.' + exit() + line = hola.stdout.readline().rstrip() + if line == '[end]': + break + result.append(line) + print 'result:' + print '\n'.join(result)