[erlang-questions] remsh

Vincent de Phily vincent.dephily@REDACTED
Fri Jul 15 20:30:04 CEST 2011

On Wednesday 13 July 2011 18:23:41 Jon Watte wrote:
> If I understand it correctly, "remsh" specifies to create an interactive
> shell conneted to the remote node, but a command-line argument is evaluated
> using the local node.
> Try evaluating it as a rpc:call expression instead? You won't need a -remsh
> at all then, instead passing the node argument to the rpc call.

That's how I understand it too, and it's really annoying that you can only use 
remsh interactively.

rpc:call/4 is fine, but it only works one call at a time, needs to send all 
the results over the wire, and becomes useless as soon as you use terms that 
are tied to the VM.

I've tried all maners of techniques to send input to a remsh: -eval, -noshell, 
-oldshell, -noinput, using a pipe, echoing in /proc/$PID/fd/0... The only 
thing that works is a hack with X that simulates keyboard input.

Another thing that works is 
erl -noinput -name foobar@REDACTED \
    -eval "try {ok,S,_} = erl_scan:string(\"$YOURCODEHERE\"),                                                                                                                                
               {ok,P} = erl_parse:parse_exprs(S),                                                                                                                                     
               {value,V,_} = rpc:call('$NODE', erl_eval, exprs, [P,[]]),                                                                                                              
               io:format(\"\\e[32mok\\e[m\n~p\n\", [V])                                                                                                                               
               _:Err -> io:format(\"\\e[31merror\\e[m\n~p\n\", [Err])
           end." \
    -s erlang halt
but it isn't much more elegant.

So I've got some nontrivial code to run remotely and automatically, but for 
various reasons I do not want to have a module loaded on the remote node that 
does the work. Most languages with an interactive shell will happily read from 
standard input instead of from the tty, but /usr/bin/erl doesn't. It has -eval 
which is great, except that it doesn't work with a remote shell. Any idea ?
Vincent de Phily

More information about the erlang-questions mailing list