Skip to content

Instantly share code, notes, and snippets.

@sasa1977
Created August 16, 2015 13:31
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sasa1977/36c91befb96412e244c6 to your computer and use it in GitHub Desktop.
Save sasa1977/36c91befb96412e244c6 to your computer and use it in GitHub Desktop.
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