Skip to content

Instantly share code, notes, and snippets.

@MartinElvar
Created August 17, 2015 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MartinElvar/8bf56945754f3b637959 to your computer and use it in GitHub Desktop.
Save MartinElvar/8bf56945754f3b637959 to your computer and use it in GitHub Desktop.
defmodule MyApp.FTP do
def open_connection(host, user, password) do
:inets.start
{host_success, pid} = :inets.start(:ftpc, [{:host, host |> to_char_list}])
login_success = :ftp.user(pid, user |> to_char_list, password |> to_char_list)
if host_success && login_success do
{:ok, pid}
else
{:error, "Could not connect to host"}
end
# :inets.stop(:ftpc, pid)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment