PaulBickford
Cannot interact with terminal spawned by port
I am trying to create a Bakeware CLI tool that takes list of servers, opens a terminal for each server, and runs the appropriate ssh command in each. I can then interact with them as needed. However, I cannot get the terminals to execute commands.
Let’s take a simple case:
iex(1)> port = Port.open({:spawn, "urxvt"}, [:binary])
spawns an Elixir process, which spawns an OS process (Linux), which spawns a child process running a terminal program (unicode rxvt). This works, it creates a terminal window.
Since a child process inherits stdin, stdout, and stderr from its parent,
iex(2)> send(port, {self(), {:command, "echo Hello"}})
should send “echo Hello” to stdin of the OS process, which, in turn, should send it to the child process stdin. However, it does not.
How can I open a terminal window and send commands to it?
Thanks! ![]()
Most Liked
hauleth
You are misunderstanding what part of the application receives messages. Sending commands to urxvt will send messages to STDIN of terminal emulator, not process running within that terminal. If you want to communicate with process within terminal, then you need to check out documentation of terminal you use. Alternatively do everything within single process.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








