-
-
Save wang-zhijun/a523a730999969b1869b to your computer and use it in GitHub Desktop.
SSH to router using Elixir
This file contains 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
:ssh.start | |
{:ok, cref} = :ssh.connect('10.55.3.1', 22, [{:user, 'user'}, {:password, 'password'}]) | |
{:ok, cid} = :ssh_connection.session_channel(cref, 5000) | |
:ssh_connection.exec(cref, cid, String.to_char_list("show ver | xml | no-more"), 3000) | |
#:ssh_connection.exec(cref, cid, String.to_char_list("show core"), 3000) | |
# need to do a receive on the cref(pid) | |
#flush() -- useful to find out what the result will look like | |
receive do | |
{:ssh_cm, _, {:data, _, _, d}} -> IO.puts d | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment