繁体   English   中英

在已经运行的shell中通过控制台运行erlang shell命令

[英]Running erlang shell command, via console, in an already-running shell

早上好 !

我正在尝试在erlang shell和只通过脚本进行通信的外部函数(zenity)之间建立通信。(它只能运行命令行)

在我的程序中,erlang shell已经运行并生成了我需要的节点。 (因此打开另一个shell来运行这些函数不起作用,并且escript打开一个新的shell。我需要从我的主shell运行这些函数)

这就是我manualy所做的,并且想编写脚本。

$ erl -name two@127.0.0.1 
Erlang/OTP 18 [erts-7.3] [source] [64-bit] [smp:4:4] [async-threads:10] [kernel-poll:false]
Eshell V7.3  (abort with ^G)
(two@127.0.0.1)1> c(client). 
{ok,client}
(two@127.0.0.1)2> client:init(). 
true
(two@127.0.0.1)3> 

client:init()生成线程。 我通过一些功能与他们沟通。

从这里开始我的不同功能

client:<function>(<Args>).

但是一个剧本

erl -name two@127.0.0.1
c(client).
client:init()
client:<function>(<Args>).

显然,它不起作用。

我可以稍微缩短一下

$ erl -name two@127.0.0.1 -s client init

但我仍然无法在创建的shell上运行函数,因为要调用的函数取决于Zenity的输出,它只通过shell命令行进行通信

是否有通过脚本运行erlang命令的解决方案?

为什么要从zenity运行命令而不只是抓取结果? (或者你可以运行echo 。)

1> Port = open_port({spawn_executable, os:find_executable("zenity")}, [in, {line, 65536}, eof, {args, ["--calendar", "--title=Holiday Planner"]}]).
#Port<0.490> 
2> flush().
Shell got {#Port<0.490>,{data,{eol,"10/20/2016"}}}
Shell got {#Port<0.490>,eof}
ok

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM