1
<?xml version="1.0" encoding="latin1" ?>
2
<!DOCTYPE chapter SYSTEM "chapter.dtd">
7
<year>2004</year><year>2009</year>
8
<holder>Ericsson AB. All Rights Reserved.</holder>
11
The contents of this file are subject to the Erlang Public License,
12
Version 1.1, (the "License"); you may not use this file except in
13
compliance with the License. You should have received a copy of the
14
Erlang Public License along with this software. If not, it can be
15
retrieved online at http://www.erlang.org/.
17
Software distributed under the License is distributed on an "AS IS"
18
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
19
the License for the specific language governing rights and limitations
24
<title>FTP Client</title>
25
<prepared>Ingela Anderton Andin</prepared>
26
<responsible></responsible>
36
<title>Introduction</title>
38
<p>Ftp clients are consider to be rather temporary and are
39
for that reason only started and stopped during
40
runtime and can not be started at application startup.
41
Due to the design of FTP client API, letting some
42
functions return intermediate results, only the process
43
that started the ftp client will be able to access it in
44
order to preserve sane semantics. (This could be solved
45
by changing the API and using the concept of a controlling
46
process more in line with other OTP applications, but
47
that is perhaps something for the future.)
48
If the process that started the ftp session
49
dies the ftp client process will terminate.</p>
51
<p>The client supports ipv6 as long as the underlying mechanisms
57
<title>Using the FTP Client API</title>
58
<p>The following is a simple example of an ftp session, where
59
the user <c>guest</c> with password <c>password</c> logs on to
60
the remote host <c>erlang.org</c>, and where the file
61
<c>appl.erl</c> is transferred from the remote to the local
62
host. When the session is opened, the current directory at
63
the remote host is <c>/home/guest</c>, and <c>/home/fred</c>
64
at the local host. Before transferring the file, the current
65
local directory is changed to <c>/home/eproj/examples</c>, and
66
the remote directory is set to
67
<c>/home/guest/appl/examples</c>.</p>
68
<code type="erl"><![CDATA[
71
2> {ok, Pid} = inets:start(ftpc, [{host, "erlang.org"}]).
73
3> ftp:user(Pid, "guest", "password").
77
5> ftp:cd(Pid, "appl/examples").
81
7> ftp:lcd(Pid, "/home/eproj/examples").
83
8> ftp:recv(Pid, "appl.erl").
85
9> inets:stop(ftpc, Pid).