Created
August 16, 2015 13:31
-
-
Save sasa1977/36c91befb96412e244c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmd = ~S""" | |
ruby -e ' | |
STDOUT.sync = true | |
context = binding | |
while (cmd = gets) do | |
eval(cmd, context) | |
end | |
' | |
""" | |
port = Port.open({:spawn, cmd}, [:binary]) | |
Port.command(port, "a = 1\n") | |
Port.command(port, "a += 2\n") | |
Port.command(port, "puts a\n") | |
receive do | |
{^port, {:data, result}} -> | |
IO.puts("Elixir got: #{inspect result}") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment