Created
August 17, 2015 10:13
-
-
Save MartinElvar/8bf56945754f3b637959 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
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