2
是否可以在Elixir中写入外部进程的stdin? NIF是目前唯一的选择吗?如何在Elixir中写入外部进程的stdin
,从药剂,块开始,等待用户输入的过程:
pid = spawn(fn ->
System.cmd("sh", [
Path.join([System.cwd, "sh", "wait_for_input"]),
"Hello world"
])
end)
我想实现这样的事情
3210这是脚本
#!/bin/sh
while read data
do
echo $data >> file_output.txt
done
查看端口:http://elixir-lang.org/docs/stable/elixir/Port.html。特别是,'Port.open/2'和'Port.command/3'。 – Dogbert
这似乎也是相关的:https://stackoverflow.com/questions/10872909/erlang-read-stdin-write-stdout – Stratus3D
@ Stratus3D我正在寻找相反的,写入标准输入。 – LemmonMaxwell