简体   繁体   中英

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

Good morning !

I'm trying to set up a communication between an erlang shell and an external function (zenity) that communicates only via scripts.(It can only run command lines)

In my program, the erlang shell is already running and spawned nodes that I need. (So opening an other shell to run the functions doesn't work, and escript opens a new shell. I need to run the functions from my main shell)

This is what I manualy do, and would like to script it.

$ 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> 

The client:init() spawns threads. And I communicate with them via some functions.

From here I run my different functions with

client:<function>(<Args>).

But a script whith

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

Obviously, it does not work.

I can shorten this a bit with

$ erl -name two@127.0.0.1 -s client init

But I still can't run functions on the shell that was created, because the function to call depends on the outputs of Zenity that only communicates via shell command lines

Are there solutions to run erlang command via a script ?

Why have you to run a command from zenity but not just grab result? (Or you can run 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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