2002-08-21 10:52:34 -04:00
|
|
|
\chapter{FTP client}\label{cha:ftp}
|
2002-02-12 06:50:54 -05:00
|
|
|
|
2003-01-16 09:12:11 -05:00
|
|
|
The \ex{ftp} structure lets you transfer files between networked
|
|
|
|
machines from the Scheme Shell, using the File Transfer Protocol as
|
|
|
|
described in RFC~959.
|
2002-02-12 06:50:54 -05:00
|
|
|
|
|
|
|
Some of the procedures in this module extract useful information from
|
|
|
|
the server's reply, such as the size of a file, or the name of the
|
2003-01-16 09:12:11 -05:00
|
|
|
directory we have moved to. These procedures return the extracted
|
|
|
|
information, or, if the server's response doesn't match the expected
|
|
|
|
code from the server, a catchable \ex{ftp-error} is raised.
|
2002-02-12 06:50:54 -05:00
|
|
|
|
2003-01-16 09:12:11 -05:00
|
|
|
\defun{ftp-connect}{host login password passive? [log-port]}{connection}
|
2002-02-12 06:50:54 -05:00
|
|
|
\begin{desc}
|
2003-01-16 09:12:11 -05:00
|
|
|
Open a command connection with the remote machine \var{host} and
|
|
|
|
login on that server with \var{login} and \var{password}.
|
|
|
|
\var{Login} and \var{password} can be \sharpf, in which case the
|
|
|
|
information is extracted from the user's \ex{.netrc} file if necessary.
|
|
|
|
|
|
|
|
If \var{log-port} is specified, it must be an output port: this
|
|
|
|
starts logging the conversation with the server to that port. Note
|
|
|
|
that the log contains passwords in clear text.
|
2002-02-12 06:50:54 -05:00
|
|
|
\end{desc}
|
|
|
|
|
2003-01-16 09:12:11 -05:00
|
|
|
\dfn{ftp-type}{\synvar{name}}{ftp-type}{syntax}
|
|
|
|
\defunx{set-ftp-type!}{connection ftp-type}{undefined}
|
2002-02-12 06:50:54 -05:00
|
|
|
\begin{desc}
|
2003-01-16 09:12:11 -05:00
|
|
|
This change the transfer mode for future file transfers. The
|
|
|
|
transfer mode is specfified by \var{ftp-type} which can be created
|
|
|
|
with the \ex{ftp-type} macro. \synvar{Name} must be either
|
|
|
|
\ex{binary} for binary data or \ex{ascii} for text.
|
2002-02-12 06:50:54 -05:00
|
|
|
\end{desc}
|
|
|
|
|
2003-01-16 09:12:11 -05:00
|
|
|
\defun{ftp-rename}{connection old new}{undefined}
|
2002-02-12 06:50:54 -05:00
|
|
|
\begin{desc}
|
2003-01-16 09:12:11 -05:00
|
|
|
This changes the name of \var{old} on the remote host to \var{new}
|
|
|
|
(assuming sufficient permissions). \var{Old} and \var{new} are
|
|
|
|
strings.
|
2002-02-12 06:50:54 -05:00
|
|
|
\end{desc}
|
|
|
|
|
2003-01-16 09:12:11 -05:00
|
|
|
\defun{ftp-delete}{connection file}{undefined}
|
2002-02-12 06:50:54 -05:00
|
|
|
\begin{desc}
|
2003-01-16 09:12:11 -05:00
|
|
|
This deletes \var{file} from the remote host (assuming the user has
|
2002-02-12 06:50:54 -05:00
|
|
|
appropriate permissions).
|
|
|
|
\end{desc}
|
|
|
|
|
2003-01-16 09:12:11 -05:00
|
|
|
\defun{ftp-cd}{connection dir}{undefined}
|
2002-02-12 06:50:54 -05:00
|
|
|
\begin{desc}
|
2003-01-16 09:12:11 -05:00
|
|
|
This changes the current directory on the server.
|
2002-02-12 06:50:54 -05:00
|
|
|
\end{desc}
|
|
|
|
|
2003-01-16 09:12:11 -05:00
|
|
|
\defun{ftp-cdup}{connection}{undefined}
|
2002-02-12 06:50:54 -05:00
|
|
|
\begin{desc}
|
2003-01-16 09:12:11 -05:00
|
|
|
This move to the parent directory on the server.
|
2002-02-12 06:50:54 -05:00
|
|
|
\end{desc}
|
|
|
|
|
2003-01-16 09:12:11 -05:00
|
|
|
\defun{ftp-pwd}{connection}{string}
|
2002-02-12 06:50:54 -05:00
|
|
|
\begin{desc}
|
|
|
|
Return the current directory on the remote host, as a string.
|
|
|
|
\end{desc}
|
|
|
|
|
2003-01-16 09:12:11 -05:00
|
|
|
\defun{ftp-ls}{connection [dir]}{list}
|
2002-02-12 06:50:54 -05:00
|
|
|
\begin{desc}
|
2003-01-16 09:12:11 -05:00
|
|
|
This returns a list of filenames on the remote host, either from the
|
|
|
|
current directory (if \var{dir} is not specified), or from the
|
|
|
|
directory specified by \var{dir}.
|
2002-02-12 06:50:54 -05:00
|
|
|
\end{desc}
|
|
|
|
|
2003-01-16 09:12:11 -05:00
|
|
|
\defun{ftp-dir}{connection [dir]}{status}
|
2002-02-12 06:50:54 -05:00
|
|
|
\begin{desc}
|
2003-01-16 09:12:11 -05:00
|
|
|
This returns a list of long-form file name entries on the remote
|
|
|
|
host, either from the current directory (if \var{dir} is not
|
|
|
|
specified), or from the directory specified by \var{dir}. (Note
|
|
|
|
that the format for the long-form entries is not specified by the
|
|
|
|
FTP standard.)
|
2002-02-12 06:50:54 -05:00
|
|
|
\end{desc}
|
|
|
|
|
2003-01-16 09:12:11 -05:00
|
|
|
\defun{ftp-get}{connection remote-file proc}{undefined}
|
2002-02-12 06:50:54 -05:00
|
|
|
\begin{desc}
|
2003-01-16 09:12:11 -05:00
|
|
|
This downloads \var{remote-file} from the FTP server.
|
|
|
|
\ex{Ftp-get} establishes a data conneciton to the server, attaches
|
|
|
|
an input port to the data connection, and calls \var{proc} on that
|
|
|
|
port.
|
2002-02-12 06:50:54 -05:00
|
|
|
\end{desc}
|
|
|
|
|
2003-01-16 09:12:11 -05:00
|
|
|
\defun{ftp-put}{connection remote-file proc}{undefined}
|
2002-02-12 06:50:54 -05:00
|
|
|
\begin{desc}
|
2003-01-16 09:12:11 -05:00
|
|
|
This uploads \var{remote-file} to the FTP server. \ex{Ftp-put}
|
|
|
|
establishes a data conneciton to the server, attaches an output port
|
|
|
|
to the data connection, and calls \var{proc} on that port.
|
2002-02-12 06:50:54 -05:00
|
|
|
\end{desc}
|
|
|
|
|
2003-01-16 09:12:11 -05:00
|
|
|
\defun{ftp-append}{connection remote-file proc}{undefined}
|
2002-04-04 10:28:45 -05:00
|
|
|
\begin{desc}
|
2003-01-16 09:12:11 -05:00
|
|
|
This appends data to \var{remote-file} on the FTP server.
|
|
|
|
\ex{Ftp-append} establishes a data conneciton to the server,
|
|
|
|
attaches an output port to the data connection, and calls \var{proc}
|
|
|
|
on that port.
|
2002-04-04 10:28:45 -05:00
|
|
|
\end{desc}
|
|
|
|
|
2003-01-16 09:12:11 -05:00
|
|
|
\defun{ftp-rmdir}{connection dir}{undefined}
|
2002-02-12 06:50:54 -05:00
|
|
|
\begin{desc}
|
2003-01-16 09:12:11 -05:00
|
|
|
This removes the directory \var{dir} from the remote host (assuming
|
2002-02-12 06:50:54 -05:00
|
|
|
sufficient permissions).
|
|
|
|
\end{desc}
|
|
|
|
|
2003-01-16 09:12:11 -05:00
|
|
|
\defun{ftp-mkdir}{connection dir}{undefined}
|
2002-02-12 06:50:54 -05:00
|
|
|
\begin{desc}
|
2003-01-16 09:12:11 -05:00
|
|
|
This create a new directory named \var{dir} on the remote host
|
2002-02-12 06:50:54 -05:00
|
|
|
(assuming sufficient permissions).
|
|
|
|
\end{desc}
|
|
|
|
|
2003-01-16 09:12:11 -05:00
|
|
|
\defun{ftp-modification-time}{connection file}{date}
|
2002-02-12 06:50:54 -05:00
|
|
|
\begin{desc}
|
2003-01-16 09:12:11 -05:00
|
|
|
This requests the time of the last modification of \var{file} on the
|
|
|
|
remote host, and on success return a Scsh date record. (This command
|
2002-02-12 06:50:54 -05:00
|
|
|
is not part of RFC~959 and is not implemented by all servers, but is
|
2003-01-16 09:12:11 -05:00
|
|
|
useful for mirroring.)
|
2002-02-12 06:50:54 -05:00
|
|
|
\end{desc}
|
|
|
|
|
2003-01-16 09:12:11 -05:00
|
|
|
\defun{ftp-size}{connection file}{integer}
|
2002-02-12 06:50:54 -05:00
|
|
|
\begin{desc}
|
2003-01-16 09:12:11 -05:00
|
|
|
This returns the size of \var{file} in bytes. (This command is not
|
|
|
|
part of RFC~959 and is not implemented by all servers.)
|
2002-02-12 06:50:54 -05:00
|
|
|
\end{desc}
|
|
|
|
|
2003-01-16 09:12:11 -05:00
|
|
|
\defun{ftp-quit}{connection}{undefined}
|
2002-02-12 06:50:54 -05:00
|
|
|
\begin{desc}
|
2003-01-16 09:12:11 -05:00
|
|
|
This closes the connection to the remote host. The \var{connection}
|
2002-02-12 06:50:54 -05:00
|
|
|
object is useless after a quit command.
|
|
|
|
\end{desc}
|
|
|
|
|
2002-04-25 05:52:42 -04:00
|
|
|
\defun{ftp-quot}{connection command}{status}
|
2002-04-04 10:28:45 -05:00
|
|
|
\begin{desc}
|
2003-01-16 09:12:11 -05:00
|
|
|
This sends a \var{command} verbatim to the remote server and wait
|
|
|
|
for a response. The response text is returned verbatim.
|
2002-04-04 10:28:45 -05:00
|
|
|
\end{desc}
|
|
|
|
|
2002-04-25 05:52:42 -04:00
|
|
|
\defun{ftp-error?}{thing}{boolean}
|
|
|
|
\begin{desc}
|
2003-01-16 09:12:11 -05:00
|
|
|
This returns \sharpt if \var{thing} is a \ex{ftp-error} object,
|
|
|
|
otherwise \sharpf.
|
2002-04-25 05:52:42 -04:00
|
|
|
\end{desc}
|
2002-02-12 06:50:54 -05:00
|
|
|
|
2003-01-16 09:12:11 -05:00
|
|
|
\defun{copy-port->port-binary}{input-port oputput-port}{undefined}
|
|
|
|
\defunx{copy-port->port-ascii}{input-port oputput-port}{undefined}
|
|
|
|
\defunx{copy-ascii-port->port}{input-port oputput-port}{undefined}
|
|
|
|
\begin{desc}
|
|
|
|
These procedures are useful for downloading and uploading data to an
|
|
|
|
FTP connection via \ex{ftp-get}, \ex{ftp-get}, and \ex{ftp-append}.
|
|
|
|
They all copy data from one port to another.
|
|
|
|
\ex{Copy-port->port-binary} copies verbatim, while the other two
|
|
|
|
perform CR/LF conversion for ASCII data transfers.
|
|
|
|
\ex{Copy-port->port-ascii} adds CR/LFs at line endings on output,
|
|
|
|
whereas \ex{Copy-ascii-port->port} removes CR/LFs at line endings
|
|
|
|
end replaces them by ordinary LFs.
|
|
|
|
\end{desc}
|
2002-02-12 06:50:54 -05:00
|
|
|
|
2002-08-21 09:35:41 -04:00
|
|
|
%%% Local Variables:
|
|
|
|
%%% mode: latex
|
2003-01-10 08:30:18 -05:00
|
|
|
%%% TeX-master: "man"
|
2002-08-21 09:35:41 -04:00
|
|
|
%%% End:
|
|
|
|
|