Sophie

Sophie

distrib > Mandriva > 8.1 > i586 > by-pkgid > 628e26a49117deea42e952d5b0d0f0d7 > files > 58

zsh-doc-4.0.2-2mdk.i586.rpm

<HTML>
<HEAD>
<!-- Created by texi2html 1.56k from ./zsh.texi on 26 June 2001 -->

<TITLE>zsh - Zftp Function System</TITLE>
</HEAD>
<BODY>
Go to the <A HREF="zsh_1.html">first</A>, <A HREF="zsh_21.html">previous</A>, <A HREF="zsh_23.html">next</A>, <A HREF="zsh_29.html">last</A> section, <A HREF="zsh_toc.html">table of contents</A>.
<P><HR><P>


<H1><A NAME="SEC162" HREF="zsh_toc.html#TOC162">Zftp Function System</A></H1>
<P>
<A NAME="IDX1456"></A>
<A NAME="IDX1457"></A>




<H2><A NAME="SEC163" HREF="zsh_toc.html#TOC163">Description</A></H2>
<P>


<P>
This describes the set of shell functions supplied with the source
distribution as an interface to the <TT>zftp</TT> builtin command, allowing you
to perform FTP operations from the shell command line or within functions
or scripts.  The interface is similar to a traditional FTP client (e.g. the
<TT>ftp</TT> command itself, see man page ftp(1)), but as it is entirely done
within the shell all the familiar completion, editing and globbing features,
and so on, are present, and macros are particularly simple to write as they
are just ordinary shell functions.


<P>
The prerequisite is that the <TT>zftp</TT> command, as described in
section <A HREF="zsh_21.html#SEC152">The zsh/zftp Module</A>
, must be available in the
version of <TT>zsh</TT> installed at your site.  If the shell is configured to
load new commands at run time, it probably is: typing `<TT>zmodload zsh/zftp</TT>'
will make sure (if that runs silently, it has worked).  If this is not the
case, it is possible <TT>zftp</TT> was linked into the shell anyway: to test
this, type `<TT>which zftp</TT>' and if <TT>zftp</TT> is available you will get the
message `<TT>zftp: shell built-in command</TT>'.


<P>
Commands given directly with <TT>zftp</TT> builtin may be interspersed between
the functions in this suite; in a few cases, using <TT>zftp</TT> directly may
cause some of the status information stored in shell parameters to become
invalid.  Note in particular the description of the variables
<TT>$ZFTP_TMOUT</TT>, <TT>$ZFTP_PREFS</TT> and <TT>$ZFTP_VERBOSE</TT> for <TT>zftp</TT>.


<P>


<P>




<H2><A NAME="SEC164" HREF="zsh_toc.html#TOC164">Installation</A></H2>
<P>


<P>
You should make sure all the functions from the <TT>Functions/Zftp</TT>
directory of the source distribution are available; they all begin with the
two letters `<TT>zf</TT>'.  They may already have been installed on your system;
otherwise, you will need to find them and copy them.  The directory should
appear as one of the elements of the <TT>$fpath</TT> array (this should already
be the case if they were installed), and at least the function <TT>zfinit</TT>
should be autoloaded; it will autoload the rest.  Finally, to initialize
the use of the system you need to call the <TT>zfinit</TT> function.  The
following code in your <TT>.zshrc</TT> will arrange for this; assume the
functions are stored in the directory <TT>~/myfns</TT>:


<P>

<PRE>
fpath=(~/myfns $fpath)
autoload -U zfinit
zfinit
</PRE>

<P>
Note that <TT>zfinit</TT> assumes you are using the <TT>zmodload</TT> method to
load the <TT>zftp</TT> command.  If it is already built into the shell, change
<TT>zfinit</TT> to <TT>zfinit -n</TT>.  It is helpful (though not essential) if the
call to <TT>zfinit</TT> appears after any code to initialize the new completion
system, else unnecessary <TT>compctl</TT> commands will be given.


<P>




<H2><A NAME="SEC165" HREF="zsh_toc.html#TOC165">Functions</A></H2>
<P>


<P>
The sequence of operations in performing a file transfer is essentially the
same as that in a standard FTP client.  Note that, due to a quirk of the
shell's <TT>getopts</TT> builtin, for those functions that handle options you
must use `<TT>-</TT><TT>-</TT>' rather than `<TT>-</TT>' to ensure the remaining arguments
are treated literally (a single `<TT>-</TT>' is treated as an argument).


<P>




<H3><A NAME="SEC166" HREF="zsh_toc.html#TOC166">Opening a connection</A></H3>
<P>
<DL COMPACT>

<DT><TT>zfparams [ <VAR>host</VAR> [ <VAR>user</VAR> [ <VAR>password</VAR> ... ] ] ]</TT>
<DD>
<A NAME="IDX1458"></A>
 
Set or show the parameters for a future <TT>zfopen</TT> with no arguments.  If
no arguments are given, the current parameters are displayed (the password
will be shown as a line of asterisks).  If a host is given, and either the
<VAR>user</VAR> or <VAR>password</VAR> is not, they will be prompted for; also, any
parameter given as `<TT>?</TT>' will be prompted for, and if the `<TT>?</TT>' is
followed by a string, that will be used as the prompt.  As <TT>zfopen</TT> calls
<TT>zfparams</TT> to store the parameters, this usually need not be called
directly.

A single argument `<TT>-</TT>' will delete the stored parameters.  This will
also cause the memory of the last directory (and so on) on the other host
to be deleted.

<A NAME="IDX1459"></A>
<DT><TT>zfopen [ -1 ] [ <VAR>host</VAR> [ <VAR>user</VAR> [ <VAR>password</VAR> [ <VAR>account</VAR> ] ] ] ]</TT>
<DD>
If <VAR>host</VAR> is present, open a connection to that host under username
<VAR>user</VAR> with password <VAR>password</VAR> (and, on the rare occasions when it
is necessary, account <VAR>account</VAR>).  If a necessary parameter is missing or
given as `<TT>?</TT>' it will be prompted for.  If <VAR>host</VAR> is not present, use
a previously stored set of parameters.

If the command was successful, and the terminal is compatible with
<TT>xterm</TT> or is <TT>sun-cmd</TT>, a summary will appear in the title bar,
giving the local <TT>host:directory</TT> and the remote <TT>host:directory</TT>;
this is handled by the function <TT>zftp_chpwd</TT>, described below.

Normally, the <VAR>host</VAR>, <VAR>user</VAR> and <VAR>password</VAR> are internally
recorded for later re-opening, either by a <TT>zfopen</TT> with no arguments, or
automatically (see below).  With the option `<TT>-1</TT>', no information is
stored.  Also, if an open command with arguments failed, the parameters
will not be retained (and any previous parameters will also be deleted).
A <TT>zfopen</TT> on its own, or a <TT>zfopen -1</TT>, never alters the stored
parameters.

Both <TT>zfopen</TT> and <TT>zfanon</TT> (but not <TT>zfparams</TT>) understand URLs of
the form <TT>ftp://</TT><VAR>host</VAR>/<VAR>path...</VAR> as meaning to connect to the
<VAR>host</VAR>, then change directory to <VAR>path</VAR> (which must be a directory,
not a file).  The `<TT>ftp://</TT>' can be omitted; the trailing `<TT>/</TT>' is enough
to trigger recognition of the <VAR>path</VAR>.  Note prefixes other than
`<TT>ftp:</TT>' are not recognized, and that all characters after the first
slash beyond <VAR>host</VAR> are significant in <VAR>path</VAR>.

<A NAME="IDX1460"></A>
<DT><TT>zfanon [ -1 ] <VAR>host</VAR></TT>
<DD>
Open a connection <VAR>host</VAR> for anonymous FTP.  The username used is
`<TT>anonymous</TT>'.  The password (which will be reported the first time) is
generated as <VAR>user</VAR><TT>@</TT><VAR>host</VAR>; this is then stored in the shell
parameter <TT>$EMAIL_ADDR</TT> which can alternatively be set manually to a
suitable string.

</DL>

<P>




<H3><A NAME="SEC167" HREF="zsh_toc.html#TOC167">Directory management</A></H3>
<P>
<DL COMPACT>

<DT><TT>zfcd [ <VAR>dir</VAR> ]</TT>
<DD>
<A NAME="IDX1461"></A>
 
<DT><TT>zfcd -</TT>
<DD>
<DT><TT>zfcd <VAR>old</VAR> <VAR>new</VAR></TT>
<DD>
Change the current directory on the remote server:  this is implemented to
have many of the features of the shell builtin <TT>cd</TT>.

In the first form with <VAR>dir</VAR> present, change to the directory <VAR>dir</VAR>.
The command `<TT>zfcd ..</TT>' is treated specially, so is guaranteed to work on
non-UNIX servers (note this is handled internally by <TT>zftp</TT>).  If <VAR>dir</VAR>
is omitted, has the effect of `<TT>zfcd ~</TT>'.

The second form changes to the directory previously current.

The third form attempts to change the current directory by replacing the
first occurrence of the string <VAR>old</VAR> with the string <VAR>new</VAR> in the
current directory.

Note that in this command, and indeed anywhere a remote filename is
expected, the string which on the local host corresponds to `<TT>~</TT>' is
converted back to a `<TT>~</TT>' before being passed to the remote machine.
This is convenient because of the way expansion is performed on the command
line before <TT>zfcd</TT> receives a string.  For example, suppose the command
is `<TT>zfcd ~/foo</TT>'.  The shell will expand this to a full path such as
`<TT>zfcd /home/user2/pws/foo</TT>'.  At this stage, <TT>zfcd</TT> recognises the
initial path as corresponding to `<TT>~</TT>' and will send the directory to
the remote host as <TT>~/foo</TT>, so that the `<TT>~</TT>' will be expanded by the
server to the correct remote host directory.  Other named directories of
the form `<TT>~name</TT>' are not treated in this fashion.

<A NAME="IDX1462"></A>
<DT><TT>zfhere</TT>
<DD>
Change directory on the remote server to the one corresponding to the
current local directory, with special handling of `<TT>~</TT>' as in <TT>zfcd</TT>.
For example, if the current local directory is <TT>~/foo/bar</TT>, then
<TT>zfhere</TT> performs the effect of `<TT>zfcd ~/foo/bar</TT>'.

<A NAME="IDX1463"></A>
<DT><TT>zfdir [ -rfd ] [ - ] [ <VAR>dir-options</VAR> ] [ <VAR>dir</VAR> ]</TT>
<DD>
Produce a long directory listing.  The arguments <VAR>dir-options</VAR> and
<VAR>dir</VAR> are passed directly to the server and their effect is
implementation dependent, but specifying a particular remote directory
<VAR>dir</VAR> is usually possible.  The output is passed through a pager
given by the environment variable <TT>$PAGER</TT> or defaulting to `<TT>more</TT>'.

The directory is usually cached for re-use.  In fact, two caches are
maintained.  One is for use when there is no <VAR>dir-options</VAR> or <VAR>dir</VAR>,
i.e. a full listing of the current remote directory; it is flushed
when the current remote directory changes.  The other is
kept for repeated use of <TT>zfdir</TT> with the same arguments; for example,
repeated use of `<TT>zfdir /pub/gnu</TT>' will only require the directory to be
retrieved on the first call.  Alternatively, this cache can be re-viewed with
the <TT>-r</TT> option.  As relative directories will confuse
<TT>zfdir</TT>, the <TT>-f</TT> option can be used to force the cache to be flushed
before the directory is listed.  The option <TT>-d</TT> will delete both
caches without showing a directory listing; it will also delete the cache
of file names in the current remote directory, if any.

<A NAME="IDX1464"></A>
<DT><TT>zfls</TT> [ <VAR>ls-options</VAR> ] [ <VAR>dir</VAR> ]
<DD>
List files on the remote server.  With no arguments, this will produce a
simple list of file names for the current remote directory.  Any arguments
are passed directly to the server.  No pager and no caching is used.

</DL>

<P>




<H3><A NAME="SEC168" HREF="zsh_toc.html#TOC168">Status commands</A></H3>
<P>
<DL COMPACT>

<DT><TT>zftype</TT> [ <VAR>type</VAR> ]
<DD>
<A NAME="IDX1465"></A>
 
With no arguments, show the type of data to be transferred, usually ASCII
or binary.  With an argument, change the type: the types `<TT>A</TT>' or
`<TT>ASCII</TT>' for ASCII data and `<TT>B</TT>' or `<TT>BINARY</TT>', `<TT>I</TT>' or
`<TT>IMAGE</TT>' for binary data are understood case-insensitively.

<A NAME="IDX1466"></A>
<DT><TT>zfstat</TT> [ -v ]
<DD>
Show the status of the current or last connection, as well as the status of
some of <TT>zftp</TT>'s status variables.  With the <TT>-v</TT> option, a more
verbose listing is produced by querying the server for its version of
events, too.

</DL>

<P>




<H3><A NAME="SEC169" HREF="zsh_toc.html#TOC169">Retrieving files</A></H3>
<P>
The commands for retrieving files all take at least two options. <TT>-G</TT>
suppresses remote filename expansion which would otherwise be performed
(see below for a more detailed description of that).  <TT>-t</TT> attempts
to set the modification time of the local file to that of the remote file:
this requires version 5 of <TT>perl</TT>, see the description of the function
<TT>zfrtime</TT> below for more information.


<P>
<DL COMPACT>

<DT><TT>zfget [ -Gtc ] <VAR>file1</VAR> ...</TT>
<DD>
<A NAME="IDX1467"></A>
 
Retrieve all the listed files <VAR>file1</VAR> ... one at a time from the remote
server.  If a file contains a `<TT>/</TT>', the full name is passed to the
remote server, but the file is stored locally under the name given by the
part after the final `<TT>/</TT>'.  The option <TT>-c</TT> (cat) forces all files to
be sent as a single stream to standard output; in this case the <TT>-t</TT>
option has no effect.

<A NAME="IDX1468"></A>
<DT><TT>zfuget [ -Gvst ] <VAR>file1</VAR> ...</TT>
<DD>
As <TT>zfget</TT>, but only retrieve files where the version on the remote
server is newer (has a later modification time), or where the local file
does not exist.  If the remote file is older but the files have different
sizes, or if the sizes are the same but the remote file is newer, the user
will usually be queried.  With the option <TT>-s</TT>, the command runs silently
and will always retrieve the file in either of those two cases.  With the
option <TT>-v</TT>, the command prints more information about the files while it
is working out whether or not to transfer them.

<A NAME="IDX1469"></A>
<DT><TT>zfcget [ -Gt ] <VAR>file1</VAR> ...</TT>
<DD>
As <TT>zfget</TT>, but if any of the local files exists, and is shorter than
the corresponding remote file, the command assumes that it is the result of
a partially completed transfer and attempts to transfer the rest of the
file.  This is useful on a poor connection which keeps failing.

Note that this requires a commonly implemented, but non-standard, version
of the FTP protocol, so is not guaranteed to work on all servers.

<A NAME="IDX1470"></A>
<DT><TT>zfgcp [ -Gt ] <VAR>remote-file</VAR> <VAR>local-file</VAR></TT>
<DD>
<DT><TT>zfgcp [ -Gt ] <VAR>rfile1</VAR> ... <VAR>ldir</VAR></TT>
<DD>
This retrieves files from the remote server with arguments behaving
similarly to the <TT>cp</TT> command.

In the first form, copy <VAR>remote-file</VAR> from the server to the local file
<VAR>local-file</VAR>.

In the second form, copy all the remote files <VAR>rfile1</VAR> ... into the
local directory <VAR>ldir</VAR> retaining the same basenames.  This assumes UNIX
directory semantics.

</DL>

<P>




<H3><A NAME="SEC170" HREF="zsh_toc.html#TOC170">Sending files</A></H3>
<P>
<DL COMPACT>

<DT><TT>zfput [ -r ] <VAR>file1</VAR> ...</TT>
<DD>
<A NAME="IDX1471"></A>
 
Send all the <VAR>file1</VAR> ... given separately to the remote server.  If a
filename contains a `<TT>/</TT>', the full filename is used locally to find the
file, but only the basename is used for the remote file name.

With the option <TT>-r</TT>, if any of the <VAR>files</VAR> are directories they are
sent recursively with all their subdirectories, including files beginning
with `<TT>.</TT>'.  This requires that the remote machine understand UNIX file
semantics, since `<TT>/</TT>' is used as a directory separator.

<A NAME="IDX1472"></A>
<DT><TT>zfuput [ -vs ] <VAR>file1</VAR> ...</TT>
<DD>
As <TT>zfput</TT>, but only send files which are newer than their local
equivalents, or if the remote file does not exist.  The logic is the same
as for <TT>zfuget</TT>, but reversed between local and remote files.

<A NAME="IDX1473"></A>
<DT><TT>zfcput <VAR>file1</VAR> ...</TT>
<DD>
As <TT>zfput</TT>, but if any remote file already exists and is shorter than the
local equivalent, assume it is the result of an incomplete transfer and
send the rest of the file to append to the existing part.  As the FTP
append command is part of the standard set, this is in principle more
likely to work than <TT>zfcget</TT>.

<A NAME="IDX1474"></A>
<DT><TT>zfpcp <VAR>local-file</VAR> <VAR>remote-file</VAR></TT>
<DD>
<DT><TT>zfpcp <VAR>lfile1</VAR> ... <VAR>rdir</VAR></TT>
<DD>
This sends files to the remote server with arguments behaving similarly to
the <TT>cp</TT> command.

With two arguments, copy <VAR>local-file</VAR> to the server as
<VAR>remote-file</VAR>.

With more than two arguments, copy all the local files <VAR>lfile1</VAR> ... into
the existing remote directory <VAR>rdir</VAR> retaining the same basenames.  This
assumes UNIX directory semantics.

A problem arises if you attempt to use <TT>zfpcp</TT> <VAR>lfile1</VAR> <VAR>rdir</VAR>,
i.e. the second form of copying but with two arguments, as the command has
no simple way of knowing if <VAR>rdir</VAR> corresponds to a directory or a
filename.  It attempts to resolve this in various ways.  First, if the
<VAR>rdir</VAR> argument is `<TT>.</TT>' or `<TT>..</TT>' or ends in a slash, it is assumed
to be a directory.  Secondly, if the operation of copying to a remote file
in the first form failed, and the remote server sends back the expected
failure code 553 and a reply including the string `<TT>Is a directory</TT>',
then <TT>zfpcp</TT> will retry using the second form.

</DL>

<P>




<H3><A NAME="SEC171" HREF="zsh_toc.html#TOC171">Closing the connection</A></H3>
<P>
<DL COMPACT>

<DT><TT>zfclose</TT>
<DD>
<A NAME="IDX1475"></A>
 
Close the connection.

</DL>

<P>




<H3><A NAME="SEC172" HREF="zsh_toc.html#TOC172">Session management</A></H3>
<P>
<DL COMPACT>

<DT><TT>zfsession</TT> [ <TT>-lvod</TT> ] [ <VAR>sessname</VAR> ]
<DD>
<A NAME="IDX1476"></A>
 
Allows you to manage multiple FTP sessions at once.  By default,
connections take place in a session called `<TT>default</TT>'; by giving the
command `<TT>zfsession</TT> <VAR>sessname</VAR>' you can change to a new or existing
session with a name of your choice.  The new session remembers its own
connection, as well as associated shell parameters, and also the host/user
parameters set by <TT>zfparams</TT>.  Hence you can have different sessions set
up to connect to different hosts, each remembering the appropriate host,
user and password.

With no arguments, <TT>zfsession</TT> prints the name of the current session;
with the option <TT>-l</TT> it lists all sessions which currently exist, and
with the option <TT>-v</TT> it gives a verbose list showing the host and
directory for each session, where the current session is marked with an
asterisk.  With <TT>-o</TT>, it will switch to the most recent previous session.

With <TT>-d</TT>, the given session (or else the current one) is removed;
everything to do with it is completely forgotten.  If it was the only
session, a new session called `<TT>default</TT>' is created and made current.
It is safest not to delete sessions while background commands using
<TT>zftp</TT> are active.

<A NAME="IDX1477"></A>
<DT><TT>zftransfer</TT> <VAR>sess1</VAR><TT>:</TT><VAR>file1</VAR> <VAR>sess2</VAR><TT>:</TT><VAR>file2</VAR>
<DD>
Transfer files between two sessions; no local copy is made.  The file
is read from the session <VAR>sess1</VAR> as <VAR>file1</VAR> and written to session
<VAR>sess1</VAR> as file <VAR>file2</VAR>; <VAR>file1</VAR> and <VAR>file2</VAR> may be relative to
the current directories of the session.  Either <VAR>sess1</VAR> or <VAR>sess2</VAR>
may be omitted (though the colon should be retained if there is a
possibility of a colon appearing in the file name) and defaults to the
current session; <VAR>file2</VAR> may be omitted or may end with a slash, in
which case the basename of <VAR>file1</VAR> will be added.  The sessions
<VAR>sess1</VAR> and <VAR>sess2</VAR> must be distinct.

The operation is performed using pipes, so it is required that the
connections still be valid in a subshell, which is not the case under some
versions operating systems, presumably due to a system bug.

</DL>

<P>




<H3><A NAME="SEC173" HREF="zsh_toc.html#TOC173">Bookmarks</A></H3>
<P>
The two functions <TT>zfmark</TT> and <TT>zfgoto</TT> allow you to `bookmark' the
present location (host, user and directory) of the current FTP connection
for later use.  The file to be used for storing and retrieving bookmarks is
given by the parameter <TT>$ZFTP_BMFILE</TT>; if not set when one of the two
functions is called, it will be set to the file <TT>.zfbkmarks</TT> in the
directory where your zsh startup files live (usually <TT>~</TT>).


<P>
<DL COMPACT>

<DT><TT>zfmark [ </TT><VAR>bookmark</VAR><TT> ]</TT>
<DD>
<A NAME="IDX1478"></A>
 
If given an argument, mark the current host, user and directory under the
name <VAR>bookmark</VAR> for later use by <TT>zfgoto</TT>.  If there is no connection
open, use the values for the last connection immediately before it was
closed; it is an error if there is none.  Any existing bookmark
under the same name will be silently replaced.

If not given an argument, list the existing bookmarks and the points to
which they refer in the form <VAR>user</VAR><TT>@</TT><VAR>host</VAR><TT>:</TT><VAR>directory</VAR>;
this is the format in which they are stored, and the file may be edited
directly.

<A NAME="IDX1479"></A>
<DT><TT>zfgoto [ -n ] </TT><VAR>bookmark</VAR>
<DD>
Return to the location given by <VAR>bookmark</VAR>, as previously set by
<TT>zfmark</TT>.  If the location has user `<TT>ftp</TT>' or `<TT>anonymous</TT>', open
the connection with <TT>zfanon</TT>, so that no password is required.  If the
user and host parameters match those stored for the current session, if
any, those will be used, and again no password is required.  Otherwise a
password will be prompted for.

With the option <TT>-n</TT>, the bookmark is taken to be a nickname stored by
the <TT>ncftp</TT> program in its bookmark file, which is assumed to be
<TT>~/.ncftp/bookmarks</TT>.  The function works identically in other ways.
Note that there is no mechanism for adding or modifying <TT>ncftp</TT> bookmarks
from the zftp functions.

</DL>

<P>




<H3><A NAME="SEC174" HREF="zsh_toc.html#TOC174">Other functions</A></H3>
<P>
Mostly, these functions will not be called directly (apart from
<TT>zfinit</TT>), but are described here for completeness.  You may wish to
alter <TT>zftp_chpwd</TT> and <TT>zftp_progress</TT>, in particular.


<P>
<DL COMPACT>

<DT><TT>zfinit [ -n ]</TT>
<DD>
<A NAME="IDX1480"></A>
 
As described above, this is used to initialize the zftp function system.
The <TT>-n</TT> option should be used if the zftp command is already built into
the shell.

<A NAME="IDX1481"></A>
<DT><TT>zfautocheck [ -dn ]</TT>
<DD>
This function is called to implement automatic reopening behaviour, as
described in more detail below.  The options must appear in the first
argument; <TT>-n</TT> prevents the command from changing to the old directory,
while <TT>-d</TT> prevents it from setting the variable <TT>do_close</TT>, which it
otherwise does as a flag for automatically closing the connection after a
transfer.  The host and directory for the last session are stored in the
variable <TT>$zflastsession</TT>, but the internal host/user/password parameters
must also be correctly set.

<A NAME="IDX1482"></A>
<DT><TT>zfcd_match <VAR>prefix</VAR> <VAR>suffix</VAR></TT>
<DD>
This performs matching for completion of remote directory names.  If the
remote server is UNIX, it will attempt to persuade the server to list the
remote directory with subdirectories marked, which usually works but is not
guaranteed.  On other hosts it simply calls <TT>zfget_match</TT> and hence
completes all files, not just directories.  On some systems, directories
may not even look like filenames.

<A NAME="IDX1483"></A>
<DT><TT>zfget_match <VAR>prefix</VAR> <VAR>suffix</VAR></TT>
<DD>
This performs matching for completion of remote filenames.  It caches files
for the current directory (only) in the shell parameter <TT>$zftp_fcache</TT>.
It is in the form to be called by the <TT>-K</TT> option of <TT>compctl</TT>, but
also works when called from a widget-style completion function with
<VAR>prefix</VAR> and <VAR>suffix</VAR> set appropriately.

<A NAME="IDX1484"></A>
<DT><TT>zfrglob <VAR>varname</VAR></TT>
<DD>
Perform remote globbing, as describes in more detail below.  <VAR>varname</VAR>
is the name of a variable containing the pattern to be expanded; if there
were any matches, the same variable will be set to the expanded set of
filenames on return.

<A NAME="IDX1485"></A>
<DT><TT>zfrtime <VAR>lfile</VAR> <VAR>rfile</VAR> [ <VAR>time</VAR> ]</TT>
<DD>
Set the local file <VAR>lfile</VAR> to have the same modification time as the
remote file <VAR>rfile</VAR>, or the explicit time <VAR>time</VAR> in FTP format
<TT>CCYYMMDDhhmmSS</TT> for the GMT timezone.

Currently this requires <TT>perl</TT> version 5 to perform the conversion from
GMT to local time.  This is unfortunately difficult to do using shell code
alone.

<A NAME="IDX1486"></A>
<DT><TT>zftp_chpwd</TT>
<DD>
This function is called every time a connection is opened, or closed, or
the remote directory changes.  This version alters the title bar of an
<TT>xterm</TT>-compatible or <TT>sun-cmd</TT> terminal emulator to reflect the 
local and remote hostnames and current directories.  It works best when
combined with the function <TT>chpwd</TT>.  In particular, a function of 
the form


<PRE>
chpwd() {
  if [[ -n $ZFTP_USER ]]; then
    zftp_chpwd
  else
    # usual chpwd e.g put host:directory in title bar
  fi
}
</PRE>

fits in well.

<A NAME="IDX1487"></A>
<DT><TT>zftp_progress</TT>
<DD>
This function shows the status of the transfer.  It will not write anything
unless the output is going to a terminal; however, if you transfer files in
the background, you should turn off progress reports by hand using
`<TT>zstyle ':zftp:*' progress none</TT>'.  Note also that if you alter it, any
output <EM>must</EM> be to standard error, as standard output may be a file
being received.  The form of the progress meter, or whether it is used at
all, can be configured without altering the function, as described in the
next section.

<A NAME="IDX1488"></A>
<DT><TT>zffcache</TT>
<DD>
This is used to implement caching of files in the current directory for
each session separately.  It is used by <TT>zfget_match</TT> and <TT>zfrglob</TT>.

</DL>

<P>




<H2><A NAME="SEC175" HREF="zsh_toc.html#TOC175">Miscellaneous Features</A></H2>
<P>


<P>




<H3><A NAME="SEC176" HREF="zsh_toc.html#TOC176">Configuration</A></H3>
<P>
<A NAME="IDX1489"></A>
<A NAME="IDX1490"></A>
<A NAME="IDX1491"></A>


<P>
Various styles are available using the standard shell style mechanism,
described in
section <A HREF="zsh_21.html#SEC161">The zsh/zutil Module</A>. Briefly, the
command `<TT>zstyle ':zftp:*'</TT> <VAR>style</VAR> <VAR>value</VAR> ...'.
defines the <VAR>style</VAR> to have value <VAR>value</VAR> (more than one may be
given, although that is not useful in the cases described here).  These
values will then be used throughout the zftp function system.  For more
precise control, the first argument, which gives a context in which the
style applies, can be modified to include a particular function, as for
example `<TT>:zftp:zfget</TT>': the style will then have the given value only
in the <TT>zfget</TT> function.  Values for the same style in different contexts
may be set; the most specific function will be used, where
strings are held to be more specific than patterns, and longer patterns and
shorter patterns.  Note that only the top level function name, as called by
the user, is used; calling of lower level functions is transparent to the
user.  Hence modifications to the title bar in <TT>zftp_chpwd</TT> use the
contexts <TT>:zftp:zfopen</TT>, <TT>:zftp:zfcd</TT>, etc., depending where it was
called from.  The following styles are understood:


<P>
<DL COMPACT>

<DT><TT>progress</TT>
<DD>
<A NAME="IDX1492"></A>
 
Controls the way that <TT>zftp_progress</TT> reports on the progress of a
transfer.  If empty, unset, or `<TT>none</TT>', no progress report is made; if
`<TT>bar</TT>' a growing bar of inverse video is shown; if `<TT>percent</TT>' (or any
other string, though this may change in future), the percentage of the file
transferred is shown.  The bar meter requires that the width of the
terminal be available via the <TT>$COLUMNS</TT> parameter (normally this is set
automatically).  If the size of the file being transferred is not
available, <TT>bar</TT> and <TT>percent</TT> meters will simply show the number of
bytes transferred so far.

When <TT>zfinit</TT> is run, if this style is not defined for the context
<TT>:zftp:*</TT>, it will be set to `bar'.

<A NAME="IDX1493"></A>
<DT><TT>update</TT>
<DD>
Specifies the minimum time interval between updates of the progress meter
in seconds.  No update is made unless new data has been received, so the
actual time interval is limited only by <TT>$ZFTP_TIMEOUT</TT>.

As described for <TT>progress</TT>, <TT>zfinit</TT> will force this to default to 1.

<A NAME="IDX1494"></A>
<DT><TT>remote-glob</TT>
<DD>
If set to `1', `yes' or `true', filename generation (globbing) is
performed on the remote machine instead of by zsh itself; see below.

<A NAME="IDX1495"></A>
<DT><TT>titlebar</TT>
<DD>
If set to `1', `yes' or `true', <TT>zftp_chpwd</TT> will put the remote host and
remote directory into the titlebar of terminal emulators such as xterm or
sun-cmd that allow this.

As described for <TT>progress</TT>, <TT>zfinit</TT> will force this to default to 1.

<A NAME="IDX1496"></A>
<DT><TT>chpwd</TT>
<DD>
If set to `1' `yes' or `true', <TT>zftp_chpwd</TT> will call the function
<TT>chpwd</TT> when a connection is closed.  This is useful if the remote host
details were put into the terminal title bar by <TT>zftp_chpwd</TT> and your
usual <TT>chpwd</TT> also modifies the title bar.

When <TT>zfinit</TT> is run, it will determine whether <TT>chpwd</TT> exists and if
so it will set the default value for the style to 1 if none exists
already.

</DL>

<P>
Note that there is also an associative array <TT>zfconfig</TT> which contains
values used by the function system.  This should not be modified or
overwritten.


<P>




<H3><A NAME="SEC177" HREF="zsh_toc.html#TOC177">Remote globbing</A></H3>
<P>
<A NAME="IDX1497"></A>


<P>
The commands for retrieving files usually perform filename generation
(globbing) on their arguments; this can be turned off by passing the option
<TT>-G</TT> to each of the commands.  Normally this operates by retrieving a
complete list of files for the directory in question, then matching these
locally against the pattern supplied.  This has the advantage that the full
range of zsh patterns (respecting the setting of the option
<TT>EXTENDED_GLOB</TT>) can be used.  However, it means that the directory part
of a filename will not be expanded and must be given exactly.  If the
remote server does not support the UNIX directory semantics, directory
handling is problematic and it is recommended that globbing only be used
within the current directory.  The list of files in the current directory,
if retrieved, will be cached, so that subsequent globs in the same
directory without an intervening <TT>zfcd</TT> are much faster.


<P>
If the <TT>remote-glob</TT> style (see above) is set, globbing is instead
performed on the remote host: the server is asked for a list of matching
files.  This is highly dependent on how the server is implemented, though
typically UNIX servers will provide support for basic glob patterns.  This
may in some cases be faster, as it avoids retrieving the entire list of
directory contents.


<P>




<H3><A NAME="SEC178" HREF="zsh_toc.html#TOC178">Automatic and temporary reopening</A></H3>
<P>
<A NAME="IDX1498"></A>


<P>
As described for the <TT>zfopen</TT> command, a subsequent <TT>zfopen</TT> with no
parameters will reopen the connection to the last host (this includes
connections made with the <TT>zfanon</TT> command).  Opened in this fashion, the
connection starts in the default remote directory and will remain open
until explicitly closed.


<P>
Automatic re-opening is also available.  If a connection is not currently
open and a command requiring a connection is given, the last connection is
implicitly reopened.  In this case the directory which was current when the
connection was closed again becomes the current directory (unless, of
course, the command given changes it).  Automatic reopening will also take
place if the connection was close by the remote server for whatever reason
(e.g. a timeout).  It is not available if the <TT>-1</TT> option to <TT>zfopen</TT>
or <TT>zfanon</TT> was used.


<P>
Furthermore, if the command issued is a file transfer, the connection will
be closed after the transfer is finished, hence providing a one-shot mode
for transfers.  This does not apply to directory changing or listing
commands; for example a <TT>zfdir</TT> may reopen a connection but will leave it
open.  Also, automatic closure will only ever happen in the same command as
automatic opening, i.e a <TT>zfdir</TT> directly followed by a <TT>zfget</TT> will
never close the connection automatically.


<P>
Information about the previous connection is given by the <TT>zfstat</TT>
function.  So, for example, if that reports:


<P>

<PRE>
Session:        default
Not connected.
Last session:   ftp.bar.com:/pub/textfiles
</PRE>

<P>
then the command <TT>zfget file.txt</TT> will attempt to reopen a connection to
<TT>ftp.bar.com</TT>, retrieve the file <TT>/pub/textfiles/file.txt</TT>, and
immediately close the connection again.  On the other hand, <TT>zfcd ..</TT>
will open the connection in the directory <TT>/pub</TT> and leave it open.


<P>
Note that all the above is local to each session; if you return to a
previous session, the connection for that session is the one which will be
reopened.


<P>




<H3><A NAME="SEC179" HREF="zsh_toc.html#TOC179">Completion</A></H3>
<P>


<P>
Completion of local and remote files, directories, sessions and bookmarks
is supported.  The older, <TT>compctl</TT>-style completion is defined when
<TT>zfinit</TT> is called; support for the new widget-based completion system is
provided in the function <TT>Completion/Zsh/Command/_zftp</TT>, which should be
installed with the other functions of the completion system and hence
should automatically be available.


<P><HR><P>
Go to the <A HREF="zsh_1.html">first</A>, <A HREF="zsh_21.html">previous</A>, <A HREF="zsh_23.html">next</A>, <A HREF="zsh_29.html">last</A> section, <A HREF="zsh_toc.html">table of contents</A>.
</BODY>
</HTML>