/usr/share/doc/zsh-common/html/Zftp-Function-System.html is in zsh-doc 5.3.1-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 6.3, http://www.gnu.org/software/texinfo/ -->
<head>
<title>zsh: 25 Zftp Function System</title>
<meta name="description" content="zsh: 25 Zftp Function System">
<meta name="keywords" content="zsh: 25 Zftp Function System">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2any">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smalllisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en">
<a name="Zftp-Function-System"></a>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="TCP-Function-System.html#TCP-Function-System" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="TCP-Function-System.html#TCP-Bugs" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="index.html#Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#Description-8" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left">[<a href="User-Contributions.html#User-Contributions" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="index.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Zftp-Function-System-1"></a>
<h1 class="chapter">25 Zftp Function System</h1>
<p><a name="index-zftp-function-system"></a>
<a name="index-FTP_002c-functions-for-using-shell-as-client"></a>
</p>
<hr>
<a name="Description-8"></a>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Zftp-Function-System" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#Zftp-Function-System" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Zftp-Function-System" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#Installation" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left">[<a href="User-Contributions.html#User-Contributions" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="index.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section">25.1 Description</h2>
<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>
<p>The prerequisite is that the <tt>zftp</tt> command, as described in
<a href="Zsh-Modules.html#The-zsh_002fzftp-Module">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>
<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>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#Installation">25.2 Installation</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#Zftp-Functions">25.3 Functions</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#Miscellaneous-Features">25.4 Miscellaneous Features</a></td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Installation"></a>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Zftp-Function-System" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#Description-8" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Zftp-Function-System" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#Zftp-Functions" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left">[<a href="User-Contributions.html#User-Contributions" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="index.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Installation-1"></a>
<h2 class="section">25.2 Installation</h2>
<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>
<div class="example">
<pre class="example">fpath=(~/myfns $fpath)
autoload -U zfinit
zfinit
</pre></div>
<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>
<hr>
<a name="Zftp-Functions"></a>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Zftp-Function-System" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#Installation" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Zftp-Function-System" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#Opening-a-connection" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left">[<a href="User-Contributions.html#User-Contributions" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="index.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Functions-4"></a>
<h2 class="section">25.3 Functions</h2>
<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>
<hr>
<a name="Opening-a-connection"></a>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Zftp-Function-System" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#Zftp-Functions" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Zftp-Functions" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#Directory-management" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left">[<a href="User-Contributions.html#User-Contributions" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="index.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection">25.3.1 Opening a connection</h3>
<dl compact="compact">
<dd><a name="index-zfparams"></a>
</dd>
<dt><tt>zfparams</tt> [ <var>host</var> [ <var>user</var> [ <var>password</var> ... ] ] ]</dt>
<dd><p>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 <var>host</var> 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.
</p>
<p>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.
</p>
<a name="index-zfopen"></a>
</dd>
<dt><tt>zfopen</tt> [ <tt>-1</tt> ] [ <var>host</var> [ <var>user</var> [ <var>password</var> [ <var>account</var> ] ] ] ]</dt>
<dd><p>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.
</p>
<p>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.
</p>
<p>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.
</p>
<p>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>.
</p>
<a name="index-zfanon"></a>
</dd>
<dt><tt>zfanon</tt> [ <tt>-1</tt> ] <var>host</var></dt>
<dd><p>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.
</p>
</dd>
</dl>
<hr>
<a name="Directory-management"></a>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Zftp-Function-System" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#Opening-a-connection" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Zftp-Functions" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#Status-commands" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left">[<a href="User-Contributions.html#User-Contributions" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="index.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection">25.3.2 Directory management</h3>
<dl compact="compact">
<dd><a name="index-zfcd"></a>
</dd>
<dt><tt>zfcd</tt> [ <var>dir</var> ]</dt>
<dt><tt>zfcd -</tt></dt>
<dt><tt>zfcd</tt> <var>old</var> <var>new</var></dt>
<dd><p>Change the current directory on the remote server: this is implemented to
have many of the features of the shell builtin <tt>cd</tt>.
</p>
<p>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>’.
</p>
<p>The second form changes to the directory previously current.
</p>
<p>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.
</p>
<p>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.
</p>
<a name="index-zfhere"></a>
</dd>
<dt><tt>zfhere</tt></dt>
<dd><p>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>’.
</p>
<a name="index-zfdir"></a>
</dd>
<dt><tt>zfdir</tt> [ <tt>-rfd</tt> ] [ <tt>-</tt> ] [ <var>dir-options</var> ] [ <var>dir</var> ]</dt>
<dd><p>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 ‘<tt>more</tt>’ if that is not
set.
</p>
<p>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.
</p>
<a name="index-zfls"></a>
</dd>
<dt><tt>zfls</tt> [ <var>ls-options</var> ] [ <var>dir</var> ]</dt>
<dd><p>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.
</p>
</dd>
</dl>
<hr>
<a name="Status-commands"></a>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Zftp-Function-System" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#Directory-management" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Zftp-Functions" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#Retrieving-files" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left">[<a href="User-Contributions.html#User-Contributions" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="index.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection">25.3.3 Status commands</h3>
<dl compact="compact">
<dd><a name="index-zftype"></a>
</dd>
<dt><tt>zftype</tt> [ <var>type</var> ]</dt>
<dd><p>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.
</p>
<a name="index-zfstat"></a>
</dd>
<dt><tt>zfstat</tt> [ <tt>-v</tt> ]</dt>
<dd><p>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.
</p>
</dd>
</dl>
<hr>
<a name="Retrieving-files"></a>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Zftp-Function-System" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#Status-commands" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Zftp-Functions" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#Sending-files" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left">[<a href="User-Contributions.html#User-Contributions" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="index.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection">25.3.4 Retrieving files</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:
see the description of the function <tt>zfrtime</tt> below for more information.
</p>
<dl compact="compact">
<dd><a name="index-zfget"></a>
</dd>
<dt><tt>zfget</tt> [ <tt>-Gtc</tt> ] <var>file1</var> ...</dt>
<dd><p>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.
</p>
<a name="index-zfuget"></a>
</dd>
<dt><tt>zfuget</tt> [ <tt>-Gvst</tt> ] <var>file1</var> ...</dt>
<dd><p>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.
</p>
<a name="index-zfcget"></a>
</dd>
<dt><tt>zfcget</tt> [ <tt>-Gt</tt> ] <var>file1</var> ...</dt>
<dd><p>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.
</p>
<p>Note that this requires a commonly implemented, but non-standard, version
of the FTP protocol, so is not guaranteed to work on all servers.
</p>
<a name="index-zfgcp"></a>
</dd>
<dt><tt>zfgcp</tt> [ <tt>-Gt</tt> ] <var>remote-file</var> <var>local-file</var></dt>
<dt><tt>zfgcp</tt> [ <tt>-Gt</tt> ] <var>rfile1</var> ... <var>ldir</var></dt>
<dd><p>This retrieves files from the remote server with arguments behaving
similarly to the <tt>cp</tt> command.
</p>
<p>In the first form, copy <var>remote-file</var> from the server to the local file
<var>local-file</var>.
</p>
<p>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.
</p>
</dd>
</dl>
<hr>
<a name="Sending-files"></a>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Zftp-Function-System" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#Retrieving-files" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Zftp-Functions" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#Closing-the-connection" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left">[<a href="User-Contributions.html#User-Contributions" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="index.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection">25.3.5 Sending files</h3>
<dl compact="compact">
<dd><a name="index-zfput"></a>
</dd>
<dt><tt>zfput</tt> [ <tt>-r</tt> ] <var>file1</var> ...</dt>
<dd><p>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.
</p>
<p>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.
</p>
<a name="index-zfuput"></a>
</dd>
<dt><tt>zfuput</tt> [ <tt>-vs</tt> ] <var>file1</var> ...</dt>
<dd><p>As <tt>zfput</tt>, but only send files which are newer than their remote
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.
</p>
<a name="index-zfcput"></a>
</dd>
<dt><tt>zfcput</tt> <var>file1</var> ...</dt>
<dd><p>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>.
</p>
<a name="index-zfpcp"></a>
</dd>
<dt><tt>zfpcp</tt> <var>local-file</var> <var>remote-file</var></dt>
<dt><tt>zfpcp</tt> <var>lfile1</var> ... <var>rdir</var></dt>
<dd><p>This sends files to the remote server with arguments behaving similarly to
the <tt>cp</tt> command.
</p>
<p>With two arguments, copy <var>local-file</var> to the server as
<var>remote-file</var>.
</p>
<p>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.
</p>
<p>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.
</p>
</dd>
</dl>
<hr>
<a name="Closing-the-connection"></a>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Zftp-Function-System" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#Sending-files" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Zftp-Functions" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#Session-management" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left">[<a href="User-Contributions.html#User-Contributions" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="index.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection">25.3.6 Closing the connection</h3>
<dl compact="compact">
<dd><a name="index-zfclose"></a>
</dd>
<dt><tt>zfclose</tt></dt>
<dd><p>Close the connection.
</p>
</dd>
</dl>
<hr>
<a name="Session-management"></a>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Zftp-Function-System" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#Closing-the-connection" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Zftp-Functions" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#Bookmarks" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left">[<a href="User-Contributions.html#User-Contributions" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="index.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection">25.3.7 Session management</h3>
<dl compact="compact">
<dd><a name="index-zfsession"></a>
</dd>
<dt><tt>zfsession</tt> [ <tt>-lvod</tt> ] [ <var>sessname</var> ]</dt>
<dd><p>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.
</p>
<p>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.
</p>
<p>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.
</p>
<a name="index-zftransfer"></a>
</dd>
<dt><tt>zftransfer</tt> <var>sess1</var><tt>:</tt><var>file1</var> <var>sess2</var><tt>:</tt><var>file2</var></dt>
<dd><p>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>sess2</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.
</p>
<p>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
versions of some operating systems, presumably due to a system bug.
</p>
</dd>
</dl>
<hr>
<a name="Bookmarks"></a>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Zftp-Function-System" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#Session-management" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Zftp-Functions" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#Other-functions" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left">[<a href="User-Contributions.html#User-Contributions" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="index.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection">25.3.8 Bookmarks</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="compact">
<dd><a name="index-zfmark"></a>
</dd>
<dt><tt>zfmark</tt> [ <var>bookmark</var> ]</dt>
<dd><p>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 was none. Any existing bookmark
under the same name will be silently replaced.
</p>
<p>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.
</p>
<a name="index-zfgoto"></a>
</dd>
<dt><tt>zfgoto</tt> [ <tt>-n</tt> ] <var>bookmark</var></dt>
<dd><p>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.
</p>
<p>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.
</p>
</dd>
</dl>
<hr>
<a name="Other-functions"></a>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Zftp-Function-System" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#Bookmarks" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Zftp-Functions" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#Miscellaneous-Features" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left">[<a href="User-Contributions.html#User-Contributions" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="index.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection">25.3.9 Other functions</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="compact">
<dd><a name="index-zfinit"></a>
</dd>
<dt><tt>zfinit</tt> [ <tt>-n</tt> ]</dt>
<dd><p>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.
</p>
<a name="index-zfautocheck"></a>
</dd>
<dt><tt>zfautocheck</tt> [ <tt>-dn</tt> ]</dt>
<dd><p>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.
</p>
<a name="index-zfcd_005fmatch"></a>
</dd>
<dt><tt>zfcd_match <var>prefix</var> <var>suffix</var></tt></dt>
<dd><p>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.
</p>
<a name="index-zfget_005fmatch"></a>
</dd>
<dt><tt>zfget_match <var>prefix</var> <var>suffix</var></tt></dt>
<dd><p>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.
</p>
<a name="index-zfrglob"></a>
</dd>
<dt><tt>zfrglob <var>varname</var></tt></dt>
<dd><p>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.
</p>
<a name="index-zfrtime"></a>
</dd>
<dt><tt>zfrtime</tt> <var>lfile</var> <var>rfile</var> [ <var>time</var> ]</dt>
<dd><p>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. This uses the shell’s
<tt>zsh/datetime</tt> module to perform the conversion from
GMT to local time.
</p>
<a name="index-zftp_005fchpwd_002c-supplied-version"></a>
</dd>
<dt><tt>zftp_chpwd</tt></dt>
<dd><p>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
</p>
<div class="example">
<pre class="example">chpwd() {
if [[ -n $ZFTP_USER ]]; then
zftp_chpwd
else
# usual chpwd e.g put host:directory in title bar
fi
}
</pre></div>
<p>fits in well.
</p>
<a name="index-zftp_005fprogress_002c-supplied-version"></a>
</dd>
<dt><tt>zftp_progress</tt></dt>
<dd><p>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.
</p>
<a name="index-zffcache"></a>
</dd>
<dt><tt>zffcache</tt></dt>
<dd><p>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>.
</p>
</dd>
</dl>
<hr>
<a name="Miscellaneous-Features"></a>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Zftp-Function-System" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#Other-functions" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Zftp-Function-System" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#Configuration" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left">[<a href="User-Contributions.html#User-Contributions" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="index.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Miscellaneous-Features-1"></a>
<h2 class="section">25.4 Miscellaneous Features</h2>
<hr>
<a name="Configuration"></a>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Zftp-Function-System" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#Miscellaneous-Features" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Miscellaneous-Features" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#Remote-globbing" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left">[<a href="User-Contributions.html#User-Contributions" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="index.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection">25.4.1 Configuration</h3>
<p><a name="index-zftp-function-system_002c-configuration"></a>
<a name="index-zftp-function-system_002c-styles"></a>
<a name="index-styles-in-zftp-functions"></a>
</p>
<p>Various styles are available using the standard shell style mechanism,
described in
<a href="Zsh-Modules.html#The-zsh_002fzutil-Module">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 value 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="compact">
<dd><a name="index-progress_002c-zftp-style"></a>
</dd>
<dt><tt>progress</tt></dt>
<dd><p>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.
</p>
<p>When <tt>zfinit</tt> is run, if this style is not defined for the context
<tt>:zftp:*</tt>, it will be set to ‘bar’.
</p>
<a name="index-update_002c-zftp-style"></a>
</dd>
<dt><tt>update</tt></dt>
<dd><p>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>.
</p>
<p>As described for <tt>progress</tt>, <tt>zfinit</tt> will force this to default to 1.
</p>
<a name="index-remote_002dglob_002c-zftp-style"></a>
</dd>
<dt><tt>remote-glob</tt></dt>
<dd><p>If set to ‘<tt>1</tt>’, ‘<tt>yes</tt>’ or ‘<tt>true</tt>’, filename generation (globbing) is
performed on the remote machine instead of by zsh itself; see below.
</p>
<a name="index-titlebar_002c-zftp-style"></a>
</dd>
<dt><tt>titlebar</tt></dt>
<dd><p>If set to ‘<tt>1</tt>’, ‘<tt>yes</tt>’ or ‘<tt>true</tt>’, <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.
</p>
<p>As described for <tt>progress</tt>, <tt>zfinit</tt> will force this to default to 1.
</p>
<a name="index-chpwd_002c-zftp-style"></a>
</dd>
<dt><tt>chpwd</tt></dt>
<dd><p>If set to ‘<tt>1</tt>’ ‘<tt>yes</tt>’ or ‘<tt>true</tt>’, <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.
</p>
<p>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.
</p>
</dd>
</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>
<hr>
<a name="Remote-globbing"></a>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Zftp-Function-System" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#Configuration" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Miscellaneous-Features" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#Automatic-and-temporary-reopening" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left">[<a href="User-Contributions.html#User-Contributions" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="index.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection">25.4.2 Remote globbing</h3>
<p><a name="index-zftp-function-system_002c-remote-globbing"></a>
</p>
<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>
<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>
<hr>
<a name="Automatic-and-temporary-reopening"></a>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Zftp-Function-System" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#Remote-globbing" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Miscellaneous-Features" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#Completion-4" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left">[<a href="User-Contributions.html#User-Contributions" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="index.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection">25.4.3 Automatic and temporary reopening</h3>
<p><a name="index-zftp-function-system_002c-automatic-reopening"></a>
</p>
<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>
<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>
<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>
<p>Information about the previous connection is given by the <tt>zfstat</tt>
function. So, for example, if that reports:
</p>
<div class="example">
<pre class="example">Session: default
Not connected.
Last session: ftp.bar.com:/pub/textfiles
</pre></div>
<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>
<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>
<hr>
<a name="Completion-4"></a>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Zftp-Function-System" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#Automatic-and-temporary-reopening" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Miscellaneous-Features" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="User-Contributions.html#User-Contributions" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left">[<a href="User-Contributions.html#User-Contributions" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="index.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection">25.4.4 Completion</h3>
<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>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Zftp-Function-System" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="User-Contributions.html#User-Contributions" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="index.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="zsh_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="Concept-Index.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="zsh_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<p><font size="-1">
This document was generated on <em>April 11, 2017</em> using <a href="http://www.gnu.org/software/texinfo/"><em>texi2any</em></a>.
</font></p>
<font size="-1">Zsh version 5.3.1, released on December 21, 2016.</font>
</body>
</html>
|