## 2 FTP Client

### 2.1 Introduction

Ftp clients are consider to be rather temporary and are for that reason only started and stopped during runtime and can not be started at application startup. Due to the design of FTP client API, letting some functions return intermediate results, only the process that started the ftp client will be able to access it in order to preserve sane semantics. (This could be solved by changing the API and using the concept of a controlling process more in line with other OTP applications, but that is perhaps something for the future.) If the process that started the ftp session dies the ftp client process will terminate.

The client supports ipv6 as long as the underlying mechanisms also do so.

### 2.2 Using the FTP Client API

The following is a simple example of an ftp session, where the user guest with password password logs on to the remote host erlang.org, and where the file appl.erl is transferred from the remote to the local host. When the session is opened, the current directory at the remote host is /home/guest, and /home/fred at the local host. Before transferring the file, the current local directory is changed to /home/eproj/examples, and the remote directory is set to /home/guest/appl/examples.

          1> inets:start().
          ok
          2> {ok, Pid} = inets:start(ftpc, [{host, "erlang.org"}]).
          {ok,<0.22.0>}
          3> ftp:user(Pid, "guest", "password").
          ok
          4> ftp:pwd(Pid).
          {ok, "/home/guest"}
          5> ftp:cd(Pid, "appl/examples").
          ok
          6> ftp:lpwd(Pid).
          {ok, "/home/fred"}.
          7> ftp:lcd(Pid, "/home/eproj/examples").
          ok
          8> ftp:recv(Pid, "appl.erl").
          ok
          9> inets:stop(ftpc, Pid).
          ok

inets 5.0.12
Copyright © 1991-2008 Ericsson AB