Skip to content

Instantly share code, notes, and snippets.

@Mroik
Last active December 20, 2022 03:20
Show Gist options
  • Save Mroik/5534847ac6c32185bdc76a327699a988 to your computer and use it in GitHub Desktop.
Save Mroik/5534847ac6c32185bdc76a327699a988 to your computer and use it in GitHub Desktop.
A simple helper function to print on a remote shell in erlang
-module(remote_print).
-export([print/3]).
print(Node, String, Args) ->
RemotePid = rpc:call(Node, erlang, whereis, [shell]), % Assume that on Node `register(shell, self())` was ran
{group_leader, RemoteGroup} = rpc:call(Node, erlang, process_info, [RemotePid, group_leader]),
spawn(Node, io, format, [RemoteGroup, String, Args]).
@Mroik
Copy link
Author

Mroik commented Dec 20, 2022

Lookup group_leader what it is and how it affects IO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment