Forked from jfayad/gist:86fa1258e3d9eddba08f707838123934
Last active
August 12, 2017 18:51
-
-
Save asonge/1b146bf6778f62906db5a0f59eeb43a7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
str = SSHEx.stream connection, 'ping -c 5 www.google.com' | |
Enum.reduce(str, {:ok, :running}, fn | |
_, {:error, reason} -> {:error, reason | |
{:stdout,row}, {:ok, :running} -> | |
IO.puts row | |
{:ok, :running} | |
{:stderr,row}, {:ok, :running} -> | |
IO.puts row | |
{:ok, :running} | |
{:status,status}, :ok -> | |
#close the SSH connection | |
:ssh.close(connection) | |
{:ok, status} | |
{:error,reason} -> | |
#close the SSH connection | |
:ssh.close(connection) | |
{:error, reason} | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment