<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
On 08/13/2012 02:54 PM, Thomas Elsgaard wrote:
<blockquote
cite="mid:CAKSYKuLFB=HOS-gAttzkALMVQ7XYcuVH4gy6QUqAN-xg_JFusQ@mail.gmail.com"
type="cite">
<pre wrap="">Hi
Does anybody have a good simple example of executing commands on a
remote server via SSH?
Nothing fancy, just something like:
------
Connect to host
Execute command '/bin/ls'
Read output from command
Close connection
------
</pre>
</blockquote>
Just do:<br>
<pre wrap=""><code>slave:start_link('nodename', 'user', "-rsh ssh").
See:
<a class="moz-txt-link-freetext" href="http://www.erlang.org/doc/man/slave.html">http://www.erlang.org/doc/man/slave.html</a>
<a class="moz-txt-link-freetext" href="http://stackoverflow.com/questions/2658912/erlang-starting-slave-node">http://stackoverflow.com/questions/2658912/erlang-starting-slave-node</a>
Keep in mind that your ssh configuration needs to be set, so you really should test it outside of Erlang before attempting the login within Erlang. Tsung does this for client machines if you wanted to see a production example (</code><code></code><a class="moz-txt-link-freetext" href="http://tsung.erlang-projects.org/">http://tsung.erlang-projects.org/</a><code>).
</code></pre>
<br>
</body>
</html>