【发布时间】:2017-05-11 14:24:32
【问题描述】:
我的 elixir 脚本似乎卡住了外部可执行文件返回的数据。
这个signer 程序接受两个参数并返回一个摘要字符串。
> # Usage: signer [datahex] [privatehex]
> ./signer 64bd... b3bd...
> 3a9c2e0220540ea2d2edbe18...
我可以手动运行它,效果很好。
但是当我用这个 elixir/erlang 代码运行它时:
"signer test string" |> String.to_char_list |> :os.cmd
它给出了一个错误:
'2017/05/11 07:16:44 编码/十六进制:无效字节:U+0074 \'t\'\n'
那么我怎样才能让 :os.cmd 不阻塞返回的字符串呢?我需要以某种方式转换它吗?
编辑:
我认为告诉你我能够让它与其他程序一起正常工作可能很重要:
"notepad test.txt" |> String.to_char_list |> :os.cmd
导致记事本打开当前工作目录中名为 test.txt 的现有文件。所以我认为问题不在于调用本身,但我知道什么?
【问题讨论】:
-
这行得通吗:
System.cmd("signer", ["test", "string"])?为了确定,./signer test string是否手动工作?