Annotation of src/usr.bin/ftp/ftp.1, Revision 1.69
1.69 ! martynas 1: .\" $OpenBSD: ftp.1,v 1.68 2008/03/10 22:56:43 espie Exp $
1.14 millert 2: .\" $NetBSD: ftp.1,v 1.22 1997/08/18 10:20:22 lukem Exp $
1.1 deraadt 3: .\"
4: .\" Copyright (c) 1985, 1989, 1990, 1993
5: .\" The Regents of the University of California. All rights reserved.
6: .\"
7: .\" Redistribution and use in source and binary forms, with or without
8: .\" modification, are permitted provided that the following conditions
9: .\" are met:
10: .\" 1. Redistributions of source code must retain the above copyright
11: .\" notice, this list of conditions and the following disclaimer.
12: .\" 2. Redistributions in binary form must reproduce the above copyright
13: .\" notice, this list of conditions and the following disclaimer in the
14: .\" documentation and/or other materials provided with the distribution.
1.39 millert 15: .\" 3. Neither the name of the University nor the names of its contributors
1.1 deraadt 16: .\" may be used to endorse or promote products derived from this software
17: .\" without specific prior written permission.
18: .\"
19: .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20: .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21: .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22: .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23: .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24: .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25: .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26: .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27: .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28: .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29: .\" SUCH DAMAGE.
30: .\"
31: .\" @(#)ftp.1 8.3 (Berkeley) 10/9/94
32: .\"
1.69 ! martynas 33: .Dd $Mdocdate: March 10 2008 $
1.1 deraadt 34: .Dt FTP 1
1.25 aaron 35: .Os
1.1 deraadt 36: .Sh NAME
37: .Nm ftp
1.42 jmc 38: .Nd ARPANET file transfer program
1.1 deraadt 39: .Sh SYNOPSIS
1.23 aaron 40: .Nm ftp
1.65 jmc 41: .Op Fl 46AadEegimnptVv
1.61 espie 42: .Op Fl k Ar seconds
1.6 millert 43: .Op Fl P Ar port
1.7 millert 44: .Op Fl r Ar seconds
1.6 millert 45: .Op Ar host Op Ar port
1.3 deraadt 46: .Nm ftp
1.65 jmc 47: .Op Fl C
1.42 jmc 48: .Op Fl o Ar output
49: .Sm off
50: .No ftp:// Oo Ar user : password No @
51: .Oc Ar host Oo : Ar port
52: .Oc No / Ar file Oo /
53: .Oc
54: .Sm on
1.3 deraadt 55: .Nm ftp
1.65 jmc 56: .Op Fl C
57: .Op Fl c Ar cookie
1.42 jmc 58: .Op Fl o Ar output
59: .Sm off
60: .No http:// Ar host Oo : Ar port
61: .Oc No / Ar file
62: .Sm on
1.3 deraadt 63: .Nm ftp
1.65 jmc 64: .Op Fl C
65: .Op Fl c Ar cookie
1.42 jmc 66: .Op Fl o Ar output
67: .Sm off
1.54 deraadt 68: .No https:// Ar host Oo : Ar port
69: .Oc No / Ar file
70: .Sm on
71: .Nm ftp
1.65 jmc 72: .Op Fl C
1.54 deraadt 73: .Op Fl o Ar output
74: .Sm off
1.42 jmc 75: .Ar host : No / Ar file Oo /
76: .Oc
77: .Sm on
1.1 deraadt 78: .Sh DESCRIPTION
1.27 aaron 79: .Nm
1.1 deraadt 80: is the user interface to the
81: .Tn ARPANET
1.48 jmc 82: standard File Transfer Protocol (FTP).
1.1 deraadt 83: The program allows a user to transfer files to and from a
84: remote network site.
1.3 deraadt 85: .Pp
1.55 jmc 86: The latter four usage formats will fetch a file using either the
87: FTP, HTTP, or HTTPS protocols into the current directory.
1.29 aaron 88: This is ideal for scripts.
89: Refer to
1.9 millert 90: .Sx AUTO-FETCHING FILES
91: below for more information.
1.7 millert 92: .Pp
1.28 aaron 93: The options are as follows:
1.32 aaron 94: .Bl -tag -width Ds
1.42 jmc 95: .It Fl 4
96: Forces
97: .Nm
98: to use IPv4 addresses only.
99: .It Fl 6
100: Forces
101: .Nm
102: to use IPv6 addresses only.
1.16 millert 103: .It Fl A
1.48 jmc 104: Force active mode FTP.
1.29 aaron 105: By default,
1.16 millert 106: .Nm
1.48 jmc 107: will try to use passive mode FTP and fall back to active mode
1.29 aaron 108: if passive is not supported by the server.
109: This option causes
1.16 millert 110: .Nm
1.29 aaron 111: to always use an active connection.
112: It is only useful for connecting
1.16 millert 113: to very old servers that do not implement passive mode properly.
1.6 millert 114: .It Fl a
115: Causes
116: .Nm
1.22 aaron 117: to bypass the normal login procedure and use an anonymous login instead.
1.63 martynas 118: .It Fl C
1.65 jmc 119: Continue a previously interrupted file transfer.
1.64 jmc 120: .Nm
121: will continue transferring from an offset equal to the length of
122: .Ar file .
1.65 jmc 123: .Pp
1.64 jmc 124: Resuming HTTP(S) transfers are only supported
125: if the remote server supports the
126: .Dq Range
127: header.
1.60 jmc 128: .It Fl c Ar cookie
129: Load a Netscape-like cookiejar file
130: for HTTP and HTTPS transfers.
1.59 pyr 131: With this option relevant cookies from the jar are sent with each HTTP(S)
132: request.
1.60 jmc 133: Setting the
134: .Ev http_cookies
135: environment variable has the same effect.
136: If both the
137: .Ev http_cookies
138: environment variable is set and the
1.59 pyr 139: .Fl c
1.60 jmc 140: argument is given, the latter takes precedence.
1.6 millert 141: .It Fl d
142: Enables debugging.
1.53 fgsch 143: .It Fl E
144: Disables EPSV/EPRT command on IPv4 connections.
1.8 kstailey 145: .It Fl e
1.29 aaron 146: Disables command line editing.
147: Useful for Emacs ange-ftp.
1.6 millert 148: .It Fl g
149: Disables file name globbing.
150: .It Fl i
151: Turns off interactive prompting during
152: multiple file transfers.
1.61 espie 153: .It Fl k Ar seconds
1.67 jmc 154: When greater than zero,
1.66 espie 155: sends a byte after each
1.61 espie 156: .Ar seconds
157: period over the control connection during long transfers,
158: so that incorrectly configured network equipment won't
1.62 jmc 159: aggressively drop it.
1.61 espie 160: The FTP protocol supports a
161: .Dv NOOP
162: command that can be used for that purpose.
163: This assumes the FTP server can deal with extra commands coming over
164: the control connection during a transfer.
165: Well-behaved servers queue those commands, and process them after the
166: transfer.
1.68 espie 167: By default,
168: .Nm
169: will send a byte every 60 seconds.
1.20 millert 170: .It Fl m
171: Causes
172: .Nm
1.21 millert 173: to always display the progress meter in cases where it would not do
174: so by default.
1.1 deraadt 175: .It Fl n
176: Restrains
1.6 millert 177: .Nm
178: from attempting
179: .Dq auto-login
180: upon initial connection.
1.1 deraadt 181: If auto-login is enabled,
1.6 millert 182: .Nm
1.1 deraadt 183: will check the
184: .Pa .netrc
1.42 jmc 185: file (see below) in the user's home directory for an entry describing
1.1 deraadt 186: an account on the remote machine.
187: If no entry exists,
1.6 millert 188: .Nm
1.1 deraadt 189: will prompt for the remote machine login name (default is the user
190: identity on the local machine), and, if necessary, prompt for a password
1.47 jmc 191: and an account with which to log in.
1.17 millert 192: .It Fl o Ar output
1.42 jmc 193: When fetching a single file or URL, save the contents in
1.17 millert 194: .Ar output .
1.22 aaron 195: To make the contents go to stdout,
1.17 millert 196: use
1.48 jmc 197: .Sq -
1.17 millert 198: for
199: .Ar output .
1.42 jmc 200: .It Fl P Ar port
201: Sets the port number to
202: .Ar port .
1.6 millert 203: .It Fl p
204: Enable passive mode operation for use behind connection filtering firewalls.
1.16 millert 205: This option has been deprecated as
206: .Nm
207: now tries to use passive mode by default, falling back to active mode
208: if the server does not support passive connections.
1.42 jmc 209: .It Fl r Ar seconds
210: Retry to connect if failed, pausing for number of
211: .Ar seconds .
1.6 millert 212: .It Fl t
213: Enables packet tracing.
1.42 jmc 214: .It Fl V
215: Disable verbose mode, overriding the default of enabled when input
216: is from a terminal.
1.6 millert 217: .It Fl v
218: Enable verbose mode.
219: This is the default if input is from a terminal.
220: Forces
221: .Nm
222: to show all responses from the remote server, as well
223: as report on data transfer statistics.
1.1 deraadt 224: .El
225: .Pp
1.43 jmc 226: The host with which
1.6 millert 227: .Nm
1.1 deraadt 228: is to communicate may be specified on the command line.
229: If this is done,
1.6 millert 230: .Nm
1.1 deraadt 231: will immediately attempt to establish a connection to an
1.48 jmc 232: FTP server on that host; otherwise,
1.6 millert 233: .Nm
1.1 deraadt 234: will enter its command interpreter and await instructions
235: from the user.
236: When
1.6 millert 237: .Nm
1.42 jmc 238: is awaiting commands, the prompt
1.51 jmc 239: .Dq ftp\*(Gt
1.1 deraadt 240: is provided to the user.
241: The following commands are recognized
242: by
1.48 jmc 243: .Nm :
1.1 deraadt 244: .Bl -tag -width Fl
245: .It Ic \&! Op Ar command Op Ar args
246: Invoke an interactive shell on the local machine.
247: If there are arguments, the first is taken to be a command to execute
248: directly, with the rest of the arguments as its arguments.
249: .It Ic \&$ Ar macro-name Op Ar args
250: Execute the macro
251: .Ar macro-name
252: that was defined with the
253: .Ic macdef
254: command.
255: Arguments are passed to the macro unglobbed.
1.42 jmc 256: .It Ic \&? Op Ar command
257: A synonym for
258: .Ic help .
1.1 deraadt 259: .It Ic account Op Ar passwd
260: Supply a supplemental password required by a remote system for access
261: to resources once a login has been successfully completed.
262: If no argument is included, the user will be prompted for an account
263: password in a non-echoing input mode.
264: .It Ic append Ar local-file Op Ar remote-file
265: Append a local file to a file on the remote machine.
266: If
267: .Ar remote-file
268: is left unspecified, the local file name is used in naming the
269: remote file after being altered by any
270: .Ic ntrans
271: or
272: .Ic nmap
273: setting.
274: File transfer uses the current settings for
1.29 aaron 275: .Ic type ,
1.1 deraadt 276: .Ic format ,
1.29 aaron 277: .Ic mode ,
1.1 deraadt 278: and
279: .Ic structure .
280: .It Ic ascii
281: Set the file transfer
282: .Ic type
283: to network
284: .Tn ASCII .
285: This is the default type.
286: .It Ic bell
287: Arrange that a bell be sounded after each file transfer
288: command is completed.
289: .It Ic binary
290: Set the file transfer
291: .Ic type
292: to support binary image transfer.
293: .It Ic bye
1.48 jmc 294: Terminate the FTP session with the remote server and exit
295: .Nm .
1.22 aaron 296: An end-of-file will also terminate the session and exit.
1.1 deraadt 297: .It Ic case
298: Toggle remote computer file name case mapping during
299: .Ic mget
300: commands.
301: When
302: .Ic case
303: is on (default is off), remote computer file names with all letters in
304: upper case are written in the local directory with the letters mapped
305: to lower case.
1.42 jmc 306: .It Ic cd Ar remote-directory
1.1 deraadt 307: Change the working directory on the remote machine
308: to
1.6 millert 309: .Ar remote-directory .
1.1 deraadt 310: .It Ic cdup
311: Change the remote machine working directory to the parent of the
312: current remote machine working directory.
313: .It Ic chmod Ar mode file-name
314: Change the permission modes of the file
315: .Ar file-name
316: on the remote
1.6 millert 317: system to
318: .Ar mode .
1.1 deraadt 319: .It Ic close
1.48 jmc 320: Terminate the FTP session with the remote server and
1.1 deraadt 321: return to the command interpreter.
322: Any defined macros are erased.
1.42 jmc 323: .It Ic cr
1.1 deraadt 324: Toggle carriage return stripping during
1.22 aaron 325: ASCII type file retrieval.
1.1 deraadt 326: Records are denoted by a carriage return/linefeed sequence
1.22 aaron 327: during ASCII type file transfer.
1.1 deraadt 328: When
1.42 jmc 329: .Ic cr
1.1 deraadt 330: is on (the default), carriage returns are stripped from this
331: sequence to conform with the
332: .Ux
1.42 jmc 333: single linefeed record delimiter.
334: Records on non-UNIX
1.1 deraadt 335: remote systems may contain single linefeeds;
1.22 aaron 336: when an ASCII type transfer is made, these linefeeds may be
1.1 deraadt 337: distinguished from a record delimiter only when
1.42 jmc 338: .Ic cr
1.1 deraadt 339: is off.
340: .It Ic debug Op Ar debug-value
341: Toggle debugging mode.
342: If an optional
343: .Ar debug-value
1.42 jmc 344: is specified, it is used to set the debugging level.
1.1 deraadt 345: When debugging is on,
1.6 millert 346: .Nm
1.7 millert 347: prints each command sent to the remote machine,
348: preceded by the string
1.51 jmc 349: .Ql --\*(Gt .
1.42 jmc 350: .It Ic delete Ar remote-file
351: Delete the file
352: .Ar remote-file
353: on the remote machine.
1.6 millert 354: .It Ic dir Op Ar remote-directory Op Ar local-file
1.30 millert 355: A synonym for
356: .Ic ls .
1.1 deraadt 357: .It Ic disconnect
358: A synonym for
1.6 millert 359: .Ic close .
360: .It Ic edit
361: Toggle command line editing, and context sensitive command and file
362: completion.
363: This is automatically enabled if input is from a terminal, and
364: disabled otherwise.
1.31 itojun 365: .It Ic epsv4
366: Toggle use of EPSV/EPRT command on IPv4 connection.
1.6 millert 367: .It Ic exit
368: A synonym for
369: .Ic bye .
1.1 deraadt 370: .It Ic form Ar format
371: Set the file transfer
372: .Ic form
373: to
1.6 millert 374: .Ar format .
1.42 jmc 375: The default format is
376: .Dq file .
377: .It Ic ftp Ar host Op Ar port
378: A synonym for
379: .Ic open .
380: .It Ic gate Op Ar host Op Ar port
381: Toggle gate-ftp mode.
382: This will not be permitted if the gate-ftp server hasn't been set
383: (either explicitly by the user, or from the
384: .Ev FTPSERVER
385: environment variable).
386: If
387: .Ar host
388: is given,
389: then gate-ftp mode will be enabled, and the gate-ftp server will be set to
390: .Ar host .
391: If
392: .Ar port
393: is also given, that will be used as the port to connect to on the
394: gate-ftp server.
1.1 deraadt 395: .It Ic get Ar remote-file Op Ar local-file
396: Retrieve the
397: .Ar remote-file
398: and store it on the local machine.
399: If the local
400: file name is not specified, it is given the same
401: name it has on the remote machine, subject to
402: alteration by the current
1.29 aaron 403: .Ic case ,
1.1 deraadt 404: .Ic ntrans ,
405: and
406: .Ic nmap
407: settings.
408: The current settings for
1.29 aaron 409: .Ic type ,
1.1 deraadt 410: .Ic form ,
1.29 aaron 411: .Ic mode ,
1.1 deraadt 412: and
413: .Ic structure
414: are used while transferring the file.
415: .It Ic glob
416: Toggle filename expansion for
1.29 aaron 417: .Ic mdelete ,
1.1 deraadt 418: .Ic mget
419: and
1.6 millert 420: .Ic mput .
1.1 deraadt 421: If globbing is turned off with
1.29 aaron 422: .Ic glob ,
1.1 deraadt 423: the file name arguments
424: are taken literally and not expanded.
425: Globbing for
426: .Ic mput
427: is done as in
428: .Xr csh 1 .
429: For
430: .Ic mdelete
431: and
1.29 aaron 432: .Ic mget ,
1.1 deraadt 433: each remote file name is expanded
434: separately on the remote machine and the lists are not merged.
435: Expansion of a directory name is likely to be
436: different from expansion of the name of an ordinary file:
1.48 jmc 437: the exact result depends on the foreign operating system and FTP server,
1.1 deraadt 438: and can be previewed by doing
1.42 jmc 439: .Dq mls remote-files - .
1.1 deraadt 440: Note:
441: .Ic mget
442: and
443: .Ic mput
444: are not meant to transfer
445: entire directory subtrees of files.
446: That can be done by
447: transferring a
448: .Xr tar 1
449: archive of the subtree (in binary mode).
1.5 kstailey 450: .It Ic hash Op Ar size
1.29 aaron 451: Toggle hash mark
452: .Pq Ql #
453: printing for each data block transferred.
1.5 kstailey 454: The size of a data block defaults to 1024 bytes.
1.6 millert 455: This can be changed by specifying
456: .Ar size
457: in bytes.
1.1 deraadt 458: .It Ic help Op Ar command
459: Print an informative message about the meaning of
1.6 millert 460: .Ar command .
1.1 deraadt 461: If no argument is given,
1.6 millert 462: .Nm
1.1 deraadt 463: prints a list of the known commands.
464: .It Ic idle Op Ar seconds
465: Set the inactivity timer on the remote server to
466: .Ar seconds
467: seconds.
468: If
469: .Ar seconds
470: is omitted, the current inactivity timer is printed.
471: .It Ic lcd Op Ar directory
472: Change the working directory on the local machine.
473: If
474: no
475: .Ar directory
476: is specified, the user's home directory is used.
1.10 millert 477: .It Ic less Ar file
478: A synonym for
479: .Ic page .
1.6 millert 480: .It Ic lpwd
481: Print the working directory on the local machine.
1.42 jmc 482: .It Ic ls Op Ar remote-directory Op Ar local-file
483: Print a listing of the contents of a directory on the remote machine.
1.30 millert 484: The listing includes any system-dependent information that the server
485: chooses to include; for example, most
486: .Ux
1.42 jmc 487: systems will produce output from the command
488: .Ql ls -l .
1.1 deraadt 489: If
490: .Ar remote-directory
491: is left unspecified, the current working directory is used.
492: If interactive prompting is on,
1.6 millert 493: .Nm
1.1 deraadt 494: will prompt the user to verify that the last argument is indeed the
495: target local file for receiving
1.6 millert 496: .Ic ls
1.1 deraadt 497: output.
498: If no local file is specified, or if
499: .Ar local-file
500: is
1.49 jmc 501: .Sq - ,
1.1 deraadt 502: the output is sent to the terminal.
503: .It Ic macdef Ar macro-name
504: Define a macro.
505: Subsequent lines are stored as the macro
1.29 aaron 506: .Ar macro-name ;
1.1 deraadt 507: a null line (consecutive newline characters
508: in a file or
509: carriage returns from the terminal) terminates macro input mode.
510: There is a limit of 16 macros and 4096 total characters in all
511: defined macros.
1.50 jmc 512: Macro names can be a maximum of 8 characters.
513: Macros are only applicable to the current session they are
514: defined in (or if defined outside a session, to the session
515: invoked with the next
516: .Ic open
517: command), and remain defined until a
1.1 deraadt 518: .Ic close
519: command is executed.
1.51 jmc 520: To invoke a macro,
1.52 jmc 521: use the
522: .Ic $
523: command (see above).
1.51 jmc 524: .Pp
1.29 aaron 525: The macro processor interprets
526: .Ql $
527: and
528: .Ql \e
529: as special characters.
530: A
531: .Ql $
532: followed by a number (or numbers) is replaced by the
1.1 deraadt 533: corresponding argument on the macro invocation command line.
1.29 aaron 534: A
535: .Ql $
536: followed by an
537: .Sq i
538: tells the macro processor that the
1.1 deraadt 539: executing macro is to be looped.
1.29 aaron 540: On the first pass
541: .Ql $i
542: is
1.1 deraadt 543: replaced by the first argument on the macro invocation command line,
544: on the second pass it is replaced by the second argument, and so on.
1.29 aaron 545: A
546: .Ql \e
547: followed by any character is replaced by that character.
548: Use the
549: .Ql \e
550: to prevent special treatment of the
551: .Ql $ .
1.1 deraadt 552: .It Ic mdelete Op Ar remote-files
553: Delete the
554: .Ar remote-files
555: on the remote machine.
556: .It Ic mdir Ar remote-files local-file
1.30 millert 557: A synonym for
558: .Ic mls .
1.1 deraadt 559: .It Ic mget Ar remote-files
560: Expand the
561: .Ar remote-files
562: on the remote machine
563: and do a
564: .Ic get
565: for each file name thus produced.
566: See
567: .Ic glob
568: for details on the filename expansion.
569: Resulting file names will then be processed according to
1.29 aaron 570: .Ic case ,
1.1 deraadt 571: .Ic ntrans ,
572: and
573: .Ic nmap
574: settings.
575: Files are transferred into the local working directory,
576: which can be changed with
577: .Ql lcd directory ;
578: new local directories can be created with
579: .Ql "\&! mkdir directory" .
580: .It Ic mkdir Ar directory-name
581: Make a directory on the remote machine.
582: .It Ic mls Ar remote-files local-file
583: Like
1.29 aaron 584: .Ic ls ,
1.1 deraadt 585: except multiple remote files may be specified,
586: and the
587: .Ar local-file
588: must be specified.
589: If interactive prompting is on,
1.6 millert 590: .Nm
1.1 deraadt 591: will prompt the user to verify that the last argument is indeed the
592: target local file for receiving
593: .Ic mls
594: output.
595: .It Ic mode Op Ar mode-name
596: Set the file transfer
597: .Ic mode
598: to
1.6 millert 599: .Ar mode-name .
1.42 jmc 600: The default mode is
601: .Dq stream
602: mode.
1.1 deraadt 603: .It Ic modtime Ar file-name
604: Show the last modification time of the file on the remote machine.
1.10 millert 605: .It Ic more Ar file
606: A synonym for
607: .Ic page .
1.1 deraadt 608: .It Ic mput Ar local-files
609: Expand wild cards in the list of local files given as arguments
610: and do a
611: .Ic put
612: for each file in the resulting list.
613: See
614: .Ic glob
615: for details of filename expansion.
616: Resulting file names will then be processed according to
617: .Ic ntrans
618: and
619: .Ic nmap
620: settings.
1.6 millert 621: .It Ic msend Ar local-files
622: A synonym for
623: .Ic mput .
1.1 deraadt 624: .It Ic newer Ar file-name
625: Get the file only if the modification time of the remote file is more
1.22 aaron 626: recent than the file on the current system.
1.1 deraadt 627: If the file does not
628: exist on the current system, the remote file is considered
1.6 millert 629: .Ic newer .
1.1 deraadt 630: Otherwise, this command is identical to
1.6 millert 631: .Ar get .
632: .It Ic nlist Op Ar remote-directory Op Ar local-file
1.30 millert 633: Print a list of the files in a
634: directory on the remote machine.
635: If
636: .Ar remote-directory
637: is left unspecified, the current working directory is used.
638: If interactive prompting is on,
639: .Nm
640: will prompt the user to verify that the last argument is indeed the
641: target local file for receiving
642: .Ic nlist
643: output.
644: If no local file is specified, or if
645: .Ar local-file
646: is
1.49 jmc 647: .Sq - ,
1.38 jmc 648: the output is sent to the terminal.
649: Note that on some servers, the
1.30 millert 650: .Ic nlist
651: command will only return information on normal files (not directories
652: or special files).
1.1 deraadt 653: .It Ic nmap Op Ar inpattern outpattern
654: Set or unset the filename mapping mechanism.
655: If no arguments are specified, the filename mapping mechanism is unset.
656: If arguments are specified, remote filenames are mapped during
657: .Ic mput
658: commands and
659: .Ic put
660: commands issued without a specified remote target filename.
661: If arguments are specified, local filenames are mapped during
662: .Ic mget
663: commands and
664: .Ic get
665: commands issued without a specified local target filename.
1.42 jmc 666: This command is useful when connecting to a non-UNIX remote computer
1.1 deraadt 667: with different file naming conventions or practices.
1.42 jmc 668: .Pp
1.1 deraadt 669: The mapping follows the pattern set by
670: .Ar inpattern
671: and
1.6 millert 672: .Ar outpattern .
1.22 aaron 673: .Ar inpattern
1.1 deraadt 674: is a template for incoming filenames (which may have already been
675: processed according to the
676: .Ic ntrans
677: and
678: .Ic case
679: settings).
680: Variable templating is accomplished by including the
1.29 aaron 681: sequences
682: .Ql $1 ,
683: .Ql $2 ,
1.44 jmc 684: \&...,
1.29 aaron 685: .Ql $9
686: in
1.6 millert 687: .Ar inpattern .
1.29 aaron 688: Use
689: .Ql \e
690: to prevent this special treatment of the
691: .Ql $
692: character.
1.1 deraadt 693: All other characters are treated literally, and are used to determine the
694: .Ic nmap
1.22 aaron 695: .Ar inpattern
1.1 deraadt 696: variable values.
1.45 jmc 697: .Pp
1.1 deraadt 698: For example, given
699: .Ar inpattern
700: $1.$2 and the remote file name "mydata.data", $1 would have the value
701: "mydata", and $2 would have the value "data".
702: The
703: .Ar outpattern
704: determines the resulting mapped filename.
1.29 aaron 705: The sequences
706: .Ql $1 ,
707: .Ql $2 ,
1.42 jmc 708: \&...,
1.29 aaron 709: .Ql $9
710: are replaced by any value resulting from the
1.1 deraadt 711: .Ar inpattern
712: template.
1.29 aaron 713: The sequence
714: .Ql $0
715: is replaced by the original filename.
1.1 deraadt 716: Additionally, the sequence
1.40 jmc 717: .Sq Op Ar seq1 , Ar seq2
1.1 deraadt 718: is replaced by
1.45 jmc 719: .Ar seq1
1.1 deraadt 720: if
721: .Ar seq1
722: is not a null string; otherwise it is replaced by
723: .Ar seq2 .
1.42 jmc 724: For example:
1.1 deraadt 725: .Pp
1.42 jmc 726: .Dl nmap $1.$2.$3 [$1,$2].[$2,file]
1.1 deraadt 727: .Pp
1.42 jmc 728: This command would yield the output filename
729: .Pa myfile.data
1.29 aaron 730: for input filenames
731: .Pa myfile.data
732: and
1.42 jmc 733: .Pa myfile.data.old ;
1.29 aaron 734: .Pa myfile.file
735: for the input filename
1.42 jmc 736: .Pa myfile ;
1.29 aaron 737: and
738: .Pa myfile.myfile
739: for the input filename
1.42 jmc 740: .Pa .myfile .
1.1 deraadt 741: Spaces may be included in
1.46 jmc 742: .Ar outpattern
743: by quoting them,
744: as in the following example:
1.42 jmc 745: .Bd -literal -offset indent
1.46 jmc 746: nmap $1.$2 "$1 $2"
1.29 aaron 747: .Ed
748: .Pp
749: Use the
750: .Ql \e
751: character to prevent special treatment
752: of the
753: .Ql $ ,
754: .Ql [ ,
755: .Ql \&] ,
756: and
757: .Ql \&,
758: characters.
1.1 deraadt 759: .It Ic ntrans Op Ar inchars Op Ar outchars
760: Set or unset the filename character translation mechanism.
761: If no arguments are specified, the filename character
762: translation mechanism is unset.
763: If arguments are specified, characters in
764: remote filenames are translated during
765: .Ic mput
766: commands and
767: .Ic put
768: commands issued without a specified remote target filename.
769: If arguments are specified, characters in
770: local filenames are translated during
771: .Ic mget
772: commands and
773: .Ic get
774: commands issued without a specified local target filename.
1.42 jmc 775: This command is useful when connecting to a non-UNIX remote computer
1.1 deraadt 776: with different file naming conventions or practices.
777: Characters in a filename matching a character in
778: .Ar inchars
779: are replaced with the corresponding character in
1.6 millert 780: .Ar outchars .
1.1 deraadt 781: If the character's position in
782: .Ar inchars
783: is longer than the length of
1.29 aaron 784: .Ar outchars ,
1.1 deraadt 785: the character is deleted from the file name.
786: .It Ic open Ar host Op Ar port
787: Establish a connection to the specified
788: .Ar host
1.48 jmc 789: FTP server.
1.42 jmc 790: An optional port number may be supplied,
1.22 aaron 791: in which case
1.6 millert 792: .Nm
1.48 jmc 793: will attempt to contact an FTP server at that port.
1.1 deraadt 794: If the
795: .Ic auto-login
796: option is on (default),
1.6 millert 797: .Nm
1.1 deraadt 798: will also attempt to automatically log the user in to
1.48 jmc 799: the FTP server (see below).
1.9 millert 800: .It Ic page Ar file
801: Retrieve
802: .Ic file
803: and display with the program defined in
1.25 aaron 804: .Ev PAGER
1.26 pjanzen 805: (defaulting to
806: .Xr more 1
807: if
808: .Ev PAGER
809: is null or not defined).
1.1 deraadt 810: .It Ic passive
1.29 aaron 811: Toggle passive mode.
1.48 jmc 812: If passive mode is turned on (default is on),
813: .Nm
814: will send a
1.57 jmc 815: .Dv EPSV
1.1 deraadt 816: command for all data connections instead of the usual
817: .Dv PORT
1.29 aaron 818: command.
819: The
1.1 deraadt 820: .Dv PASV
821: command requests that the remote server open a port for the data connection
1.29 aaron 822: and return the address of that port.
823: The remote server listens on that port and the client connects to it.
824: When using the more traditional
1.1 deraadt 825: .Dv PORT
826: command, the client listens on a port and sends that address to the remote
1.29 aaron 827: server, who connects back to it.
828: Passive mode is useful when using
1.6 millert 829: .Nm
1.1 deraadt 830: through a gateway router or host that controls the directionality of
831: traffic.
1.48 jmc 832: (Note that though FTP servers are required to support the
1.1 deraadt 833: .Dv PASV
834: command by RFC 1123, some do not.)
1.6 millert 835: .It Ic preserve
836: Toggle preservation of modification times on retrieved files.
837: .It Ic progress
838: Toggle display of transfer progress bar.
1.9 millert 839: The progress bar will be disabled for a transfer that has
840: .Ar local-file
841: as
1.48 jmc 842: .Sq -
1.9 millert 843: or a command that starts with
844: .Sq \&| .
845: Refer to
846: .Sx FILE NAMING CONVENTIONS
847: for more information.
1.1 deraadt 848: .It Ic prompt
849: Toggle interactive prompting.
850: Interactive prompting
851: occurs during multiple file transfers to allow the
852: user to selectively retrieve or store files.
853: If prompting is turned off (default is on), any
854: .Ic mget
855: or
856: .Ic mput
857: will transfer all files, and any
858: .Ic mdelete
859: will delete all files.
1.6 millert 860: .Pp
861: When prompting is on, the following commands are available at a prompt:
862: .Bl -tag -width 2n -offset indent
1.69 ! martynas 863: .It Ic ?\&
! 864: Print help message.
1.6 millert 865: .It Ic a
866: Answer
1.22 aaron 867: .Dq yes
868: to the current file and automatically answer
869: .Dq yes
1.6 millert 870: to any remaining files for the current command.
1.42 jmc 871: .It Ic n
872: Do not transfer the file.
1.6 millert 873: .It Ic p
874: Answer
1.22 aaron 875: .Dq yes
876: to the current file and turn off prompt mode
877: (as if
1.6 millert 878: .Dq prompt off
879: had been given).
1.69 ! martynas 880: .It Ic q
! 881: Answer
! 882: .Dq no
! 883: to the current file and automatically answer
! 884: .Dq no
! 885: to any remaining files for the current command.
1.42 jmc 886: .It Ic y
887: Transfer the file.
1.6 millert 888: .El
1.1 deraadt 889: .It Ic proxy Ar ftp-command
1.48 jmc 890: Execute an FTP command on a secondary control connection.
891: This command allows simultaneous connection to two remote FTP
1.1 deraadt 892: servers for transferring files between the two servers.
893: The first
894: .Ic proxy
895: command should be an
1.29 aaron 896: .Ic open ,
1.1 deraadt 897: to establish the secondary control connection.
1.29 aaron 898: Enter the command
1.41 jmc 899: .Ic proxy ?\&
1.48 jmc 900: to see other FTP commands executable on the
1.1 deraadt 901: secondary connection.
902: The following commands behave differently when prefaced by
1.29 aaron 903: .Ic proxy :
1.1 deraadt 904: .Ic open
1.42 jmc 905: will not define new macros during the auto-login process;
1.1 deraadt 906: .Ic close
1.42 jmc 907: will not erase existing macro definitions;
1.1 deraadt 908: .Ic get
909: and
910: .Ic mget
911: transfer files from the host on the primary control connection
1.42 jmc 912: to the host on the secondary control connection; and
1.29 aaron 913: .Ic put ,
1.1 deraadt 914: .Ic mput ,
915: and
916: .Ic append
917: transfer files from the host on the secondary control connection
918: to the host on the primary control connection.
1.48 jmc 919: Third party file transfers depend upon support of the FTP protocol
1.1 deraadt 920: .Dv PASV
921: command by the server on the secondary control connection.
922: .It Ic put Ar local-file Op Ar remote-file
923: Store a local file on the remote machine.
924: If
925: .Ar remote-file
926: is left unspecified, the local file name is used
927: after processing according to any
928: .Ic ntrans
929: or
930: .Ic nmap
931: settings
932: in naming the remote file.
933: File transfer uses the
934: current settings for
1.29 aaron 935: .Ic type ,
1.1 deraadt 936: .Ic format ,
1.29 aaron 937: .Ic mode ,
1.1 deraadt 938: and
1.6 millert 939: .Ic structure .
1.1 deraadt 940: .It Ic pwd
941: Print the name of the current working directory on the remote
942: machine.
943: .It Ic quit
944: A synonym for
1.6 millert 945: .Ic bye .
1.1 deraadt 946: .It Ic quote Ar arg1 arg2 ...
1.48 jmc 947: The arguments specified are sent, verbatim, to the remote FTP server.
1.1 deraadt 948: .It Ic recv Ar remote-file Op Ar local-file
1.6 millert 949: A synonym for
950: .Ic get .
1.1 deraadt 951: .It Ic reget Ar remote-file Op Ar local-file
952: Reget acts like get, except that if
953: .Ar local-file
954: exists and is
955: smaller than
1.29 aaron 956: .Ar remote-file ,
1.1 deraadt 957: .Ar local-file
958: is presumed to be
959: a partially transferred copy of
960: .Ar remote-file
961: and the transfer
962: is continued from the apparent point of failure.
963: This command
964: is useful when transferring very large files over networks that
965: are prone to dropping connections.
1.6 millert 966: .It Ic rename Op Ar from Op Ar to
1.1 deraadt 967: Rename the file
968: .Ar from
1.22 aaron 969: on the remote machine to the file
1.6 millert 970: .Ar to .
1.1 deraadt 971: .It Ic reset
972: Clear reply queue.
973: This command re-synchronizes command/reply sequencing with the remote
1.48 jmc 974: FTP server.
975: Resynchronization may be necessary following a violation of the FTP protocol
1.1 deraadt 976: by the remote server.
977: .It Ic restart Ar marker
978: Restart the immediately following
979: .Ic get
980: or
981: .Ic put
982: at the
983: indicated
1.6 millert 984: .Ar marker .
1.1 deraadt 985: On
986: .Ux
1.22 aaron 987: systems,
988: .Ar marker
989: is usually a byte
1.1 deraadt 990: offset into the file.
1.42 jmc 991: .It Ic rhelp Op Ar command-name
1.48 jmc 992: Request help from the remote FTP server.
1.42 jmc 993: If a
994: .Ar command-name
995: is specified, it is supplied to the server as well.
1.1 deraadt 996: .It Ic rmdir Ar directory-name
997: Delete a directory on the remote machine.
1.42 jmc 998: .It Ic rstatus Op Ar file-name
999: With no arguments, show status of remote machine.
1000: If
1001: .Ar file-name
1002: is specified, show status of
1003: .Ar file-name
1004: on remote machine.
1.1 deraadt 1005: .It Ic runique
1006: Toggle storing of files on the local system with unique filenames.
1007: If a file already exists with a name equal to the target
1008: local filename for a
1009: .Ic get
1010: or
1011: .Ic mget
1.29 aaron 1012: command, a
1.42 jmc 1013: .Dq .1
1.29 aaron 1014: is appended to the name.
1.1 deraadt 1015: If the resulting name matches another existing file,
1.29 aaron 1016: a
1.42 jmc 1017: .Dq .2
1.29 aaron 1018: is appended to the original name.
1019: If this process continues up to
1.42 jmc 1020: .Dq .99 ,
1021: an error message is printed, and the transfer does not take place.
1.1 deraadt 1022: The generated unique filename will be reported.
1023: Note that
1024: .Ic runique
1025: will not affect local files generated from a shell command
1026: (see below).
1027: The default value is off.
1028: .It Ic send Ar local-file Op Ar remote-file
1.6 millert 1029: A synonym for
1030: .Ic put .
1.1 deraadt 1031: .It Ic sendport
1032: Toggle the use of
1033: .Dv PORT
1034: commands.
1035: By default,
1.6 millert 1036: .Nm
1.1 deraadt 1037: will attempt to use a
1038: .Dv PORT
1039: command when establishing
1040: a connection for each data transfer.
1041: The use of
1042: .Dv PORT
1043: commands can prevent delays
1044: when performing multiple file transfers.
1045: If the
1046: .Dv PORT
1047: command fails,
1.6 millert 1048: .Nm
1.1 deraadt 1049: will use the default data port.
1050: When the use of
1051: .Dv PORT
1052: commands is disabled, no attempt will be made to use
1053: .Dv PORT
1054: commands for each data transfer.
1.48 jmc 1055: This is useful for certain FTP implementations which do ignore
1.1 deraadt 1056: .Dv PORT
1057: commands but, incorrectly, indicate they've been accepted.
1058: .It Ic site Ar arg1 arg2 ...
1.48 jmc 1059: The arguments specified are sent, verbatim, to the remote FTP server as a
1.1 deraadt 1060: .Dv SITE
1061: command.
1062: .It Ic size Ar file-name
1063: Return size of
1064: .Ar file-name
1065: on remote machine.
1066: .It Ic status
1067: Show the current status of
1.48 jmc 1068: .Nm .
1.42 jmc 1069: .\" .It Ic struct Op Ar struct-name
1070: .\" Set the file transfer
1071: .\" .Ar structure
1072: .\" to
1073: .\" .Ar struct-name .
1074: .\" By default,
1075: .\" .Dq file
1076: .\" structure is used.
1.1 deraadt 1077: .It Ic sunique
1078: Toggle storing of files on remote machine under unique file names.
1.48 jmc 1079: The remote FTP server must support the FTP protocol
1.1 deraadt 1080: .Dv STOU
1081: command for
1082: successful completion.
1.42 jmc 1083: The remote server will report the unique name.
1.1 deraadt 1084: Default value is off.
1085: .It Ic system
1086: Show the type of operating system running on the remote machine.
1087: .It Ic tenex
1088: Set the file transfer type to that needed to
1089: talk to
1090: .Tn TENEX
1091: machines.
1092: .It Ic trace
1093: Toggle packet tracing.
1094: .It Ic type Op Ar type-name
1095: Set the file transfer
1096: .Ic type
1097: to
1.6 millert 1098: .Ar type-name .
1.1 deraadt 1099: If no type is specified, the current type
1100: is printed.
1.42 jmc 1101: The default type is
1102: .Dq binary .
1.1 deraadt 1103: .It Ic umask Op Ar newmask
1104: Set the default umask on the remote server to
1.6 millert 1105: .Ar newmask .
1.1 deraadt 1106: If
1107: .Ar newmask
1108: is omitted, the current umask is printed.
1109: .It Xo
1110: .Ic user Ar user-name
1.6 millert 1111: .Op Ar password Op Ar account
1.1 deraadt 1112: .Xc
1.48 jmc 1113: Identify yourself to the remote FTP server.
1.1 deraadt 1114: If the
1115: .Ar password
1116: is not specified and the server requires it,
1.6 millert 1117: .Nm
1.1 deraadt 1118: will prompt the user for it (after disabling local echo).
1119: If an
1120: .Ar account
1.48 jmc 1121: field is not specified, and the FTP server requires it,
1122: the user will be prompted for it.
1.1 deraadt 1123: If an
1124: .Ar account
1125: field is specified, an account command will
1126: be relayed to the remote server after the login sequence
1127: is completed if the remote server did not require it
1128: for logging in.
1129: Unless
1.6 millert 1130: .Nm
1.42 jmc 1131: is invoked with
1132: .Dq auto-login
1133: disabled, this process is done automatically on initial connection to the
1.48 jmc 1134: FTP server.
1.1 deraadt 1135: .It Ic verbose
1136: Toggle verbose mode.
1137: In verbose mode, all responses from
1.48 jmc 1138: the FTP server are displayed to the user.
1.1 deraadt 1139: In addition,
1140: if verbose is on, when a file transfer completes, statistics
1141: regarding the efficiency of the transfer are reported.
1142: By default,
1143: verbose is on.
1144: .El
1145: .Pp
1146: Command arguments which have embedded spaces may be quoted with
1.29 aaron 1147: quote
1.42 jmc 1148: .Pq Ql \&"
1.29 aaron 1149: marks.
1.6 millert 1150: .Pp
1151: Commands which toggle settings can take an explicit
1152: .Ic on
1153: or
1154: .Ic off
1155: argument to force the setting appropriately.
1156: .Pp
1157: If
1158: .Nm
1159: receives a
1160: .Dv SIGINFO
1161: (see the
1162: .Dq status
1163: argument of
1164: .Xr stty 1 )
1165: signal whilst a transfer is in progress, the current transfer rate
1166: statistics will be written to the standard error output, in the
1167: same format as the standard completion message.
1168: .Sh AUTO-FETCHING FILES
1169: In addition to standard commands, this version of
1170: .Nm
1171: supports an auto-fetch feature.
1172: To enable auto-fetch, simply pass the list of hostnames/files
1173: on the command line.
1174: .Pp
1175: The following formats are valid syntax for an auto-fetch element:
1.56 ray 1176: .Bl -tag -width Ds
1.42 jmc 1177: .It host:/file[/]
1.6 millert 1178: .Dq Classic
1.48 jmc 1179: .Nm
1180: format.
1.42 jmc 1181: .It ftp://[user:password@]host[:port]/file[/]
1.48 jmc 1182: An FTP URL, retrieved using the FTP protocol if
1.10 millert 1183: .Ev ftp_proxy
1184: isn't defined.
1.48 jmc 1185: Otherwise, transfer using HTTP via the proxy defined in
1.10 millert 1186: .Ev ftp_proxy .
1.11 millert 1187: If
1.42 jmc 1188: .Ar user : Ns Ar password Ns @
1.11 millert 1189: is given and
1190: .Ev ftp_proxy
1.47 jmc 1191: isn't defined, log in as
1.11 millert 1192: .Ar user
1193: with a password of
1194: .Ar password .
1.6 millert 1195: .It http://host[:port]/file
1.48 jmc 1196: An HTTP URL, retrieved using the HTTP protocol.
1.6 millert 1197: If
1198: .Ev http_proxy
1199: is defined, it is used as a URL to an HTTP proxy server.
1.54 deraadt 1200: .It https://host[:port]/file
1201: An HTTPS URL, retrieved using the HTTPS protocol.
1202: If
1203: .Ev http_proxy
1204: is defined, this HTTPS proxy server will be used to fetch the
1205: file using the CONNECT method.
1.6 millert 1206: .El
1207: .Pp
1.48 jmc 1208: If a classic format or an FTP URL format has a trailing
1.6 millert 1209: .Sq / ,
1210: then
1211: .Nm
1212: will connect to the site and
1213: .Ic cd
1214: to the directory given as the path, and leave the user in interactive
1215: mode ready for further input.
1216: .Pp
1.48 jmc 1217: If successive auto-fetch FTP elements refer to the same host, then
1.6 millert 1218: the connection is maintained between transfers, reducing overhead on
1219: connection creation and deletion.
1.9 millert 1220: .Pp
1221: If
1.42 jmc 1222: .Ar file
1223: contains a glob character and globbing is enabled
1.9 millert 1224: (see
1.13 millert 1225: .Ic glob ) ,
1.9 millert 1226: then the equivalent of
1.42 jmc 1227: .Ic mget Ar file
1.9 millert 1228: is performed.
1229: .Pp
1.19 d 1230: If no
1231: .Fl o
1232: option is specified, and
1233: the directory component of
1.42 jmc 1234: .Ar file
1.9 millert 1235: contains no globbing characters,
1.19 d 1236: then
1.9 millert 1237: it is stored in the current directory as the
1238: .Xr basename 1
1239: of
1.42 jmc 1240: .Ar file .
1241: If
1242: .Fl o Ar output
1243: is specified, then
1244: .Ar file
1245: is stored as
1246: .Ar output .
1.9 millert 1247: Otherwise, the remote name is used as the local name.
1.1 deraadt 1248: .Sh ABORTING A FILE TRANSFER
1249: To abort a file transfer, use the terminal interrupt key
1250: (usually Ctrl-C).
1251: Sending transfers will be immediately halted.
1.48 jmc 1252: Receiving transfers will be halted by sending an FTP protocol
1.1 deraadt 1253: .Dv ABOR
1254: command to the remote server, and discarding any further data received.
1255: The speed at which this is accomplished depends upon the remote
1256: server's support for
1257: .Dv ABOR
1258: processing.
1259: If the remote server does not support the
1260: .Dv ABOR
1261: command, an
1.51 jmc 1262: .Ql ftp\*(Gt
1.1 deraadt 1263: prompt will not appear until the remote server has completed
1264: sending the requested file.
1265: .Pp
1266: The terminal interrupt key sequence will be ignored when
1.6 millert 1267: .Nm
1.1 deraadt 1268: has completed any local processing and is awaiting a reply
1269: from the remote server.
1270: A long delay in this mode may result from the ABOR processing described
1271: above, or from unexpected behavior by the remote server, including
1.48 jmc 1272: violations of the FTP protocol.
1.1 deraadt 1273: If the delay results from unexpected remote server behavior, the local
1.6 millert 1274: .Nm
1.1 deraadt 1275: program must be killed by hand.
1276: .Sh FILE NAMING CONVENTIONS
1277: Files specified as arguments to
1.6 millert 1278: .Nm
1.1 deraadt 1279: commands are processed according to the following rules.
1280: .Bl -enum
1281: .It
1282: If the file name
1.48 jmc 1283: .Sq -
1.29 aaron 1284: is specified, the standard input (for reading)
1285: or standard output (for writing)
1286: is used.
1.1 deraadt 1287: .It
1288: If the first character of the file name is
1289: .Sq \&| ,
1290: the
1291: remainder of the argument is interpreted as a shell command.
1.6 millert 1292: .Nm
1.1 deraadt 1293: then forks a shell, using
1294: .Xr popen 3
1.29 aaron 1295: with the argument supplied, and reads (writes) from the standard output
1296: (standard input).
1.1 deraadt 1297: If the shell command includes spaces, the argument
1.29 aaron 1298: must be quoted; e.g.,
1.42 jmc 1299: .Qq ls -lt .
1.1 deraadt 1300: A particularly
1.42 jmc 1301: useful example of this mechanism is:
1302: .Qq dir |more .
1.1 deraadt 1303: .It
1.29 aaron 1304: Failing the above checks, if
1305: .Dq globbing
1306: is enabled,
1.1 deraadt 1307: local file names are expanded
1308: according to the rules used in the
1.29 aaron 1309: .Xr csh 1 ;
1.1 deraadt 1310: c.f. the
1311: .Ic glob
1312: command.
1313: If the
1.6 millert 1314: .Nm
1.29 aaron 1315: command expects a single local file (e.g.,
1316: .Ic put ) ,
1317: only the first filename generated by the
1318: .Dq globbing
1319: operation is used.
1.1 deraadt 1320: .It
1321: For
1322: .Ic mget
1323: commands and
1324: .Ic get
1325: commands with unspecified local file names, the local filename is
1326: the remote filename, which may be altered by a
1.29 aaron 1327: .Ic case ,
1.1 deraadt 1328: .Ic ntrans ,
1329: or
1330: .Ic nmap
1331: setting.
1332: The resulting filename may then be altered if
1333: .Ic runique
1334: is on.
1335: .It
1336: For
1337: .Ic mput
1338: commands and
1339: .Ic put
1340: commands with unspecified remote file names, the remote filename is
1341: the local filename, which may be altered by a
1342: .Ic ntrans
1343: or
1344: .Ic nmap
1345: setting.
1346: The resulting filename may then be altered by the remote server if
1347: .Ic sunique
1348: is on.
1349: .El
1350: .Sh FILE TRANSFER PARAMETERS
1351: The FTP specification specifies many parameters which may
1352: affect a file transfer.
1353: The
1354: .Ic type
1.42 jmc 1355: may be one of
1356: .Dq ascii ,
1357: .Dq binary ,
1358: .Dq image ,
1359: .Dq ebcdic
1360: .Pq currently not supported
1361: or
1362: .Dq tenex
1363: (local byte size 8, for PDP-10's and PDP-20's mostly).
1.6 millert 1364: .Nm
1.38 jmc 1365: supports the ASCII and image types of file transfer,
1.1 deraadt 1366: plus local byte size 8 for
1367: .Ic tenex
1368: mode transfers.
1369: .Pp
1.6 millert 1370: .Nm
1.1 deraadt 1371: supports only the default values for the remaining
1372: file transfer parameters:
1.29 aaron 1373: .Ic mode ,
1.1 deraadt 1374: .Ic form ,
1375: and
1.6 millert 1376: .Ic struct .
1.1 deraadt 1377: .Sh THE .netrc FILE
1378: The
1379: .Pa .netrc
1380: file contains login and initialization information
1381: used by the auto-login process.
1382: It resides in the user's home directory.
1383: The following tokens are recognized; they may be separated by spaces,
1384: tabs, or new-lines:
1385: .Bl -tag -width password
1386: .It Ic machine Ar name
1387: Identify a remote machine
1388: .Ar name .
1389: The auto-login process searches the
1390: .Pa .netrc
1391: file for a
1392: .Ic machine
1393: token that matches the remote machine specified on the
1.6 millert 1394: .Nm
1.1 deraadt 1395: command line or as an
1396: .Ic open
1397: command argument.
1398: Once a match is made, the subsequent
1399: .Pa .netrc
1400: tokens are processed,
1401: stopping when the end of file is reached or another
1402: .Ic machine
1403: or a
1404: .Ic default
1405: token is encountered.
1406: .It Ic default
1407: This is the same as
1408: .Ic machine
1409: .Ar name
1410: except that
1411: .Ic default
1412: matches any name.
1413: There can be only one
1414: .Ic default
1415: token, and it must be after all
1416: .Ic machine
1417: tokens.
1418: This is normally used as:
1419: .Pp
1420: .Dl default login anonymous password user@site
1421: .Pp
1422: thereby giving the user
1423: .Ar automatic
1.48 jmc 1424: anonymous FTP login to
1.1 deraadt 1425: machines not specified in
1426: .Pa .netrc .
1427: This can be overridden
1428: by using the
1429: .Fl n
1430: flag to disable auto-login.
1431: .It Ic login Ar name
1432: Identify a user on the remote machine.
1433: If this token is present, the auto-login process will initiate
1434: a login using the specified
1435: .Ar name .
1436: .It Ic password Ar string
1437: Supply a password.
1438: If this token is present, the auto-login process will supply the
1439: specified string if the remote server requires a password as part
1440: of the login process.
1441: Note that if this token is present in the
1442: .Pa .netrc
1443: file for any user other
1444: than
1.29 aaron 1445: .Ar anonymous ,
1.6 millert 1446: .Nm
1.1 deraadt 1447: will abort the auto-login process if the
1448: .Pa .netrc
1449: is readable by
1450: anyone besides the user.
1451: .It Ic account Ar string
1452: Supply an additional account password.
1453: If this token is present, the auto-login process will supply the
1454: specified string if the remote server requires an additional
1455: account password, or the auto-login process will initiate an
1456: .Dv ACCT
1457: command if it does not.
1458: .It Ic macdef Ar name
1459: Define a macro.
1460: This token functions like the
1.6 millert 1461: .Nm
1.1 deraadt 1462: .Ic macdef
1463: command functions.
1464: A macro is defined with the specified name; its contents begin with the
1465: next
1466: .Pa .netrc
1467: line and continue until a null line (consecutive new-line
1468: characters) is encountered.
1.50 jmc 1469: Like the other tokens in the
1470: .Pa .netrc
1471: file, a
1472: .Ic macdef
1473: is applicable only to the
1474: .Ic machine
1475: definition preceding it.
1476: A
1477: .Ic macdef
1478: entry cannot be utilized by multiple
1479: .Ic machine
1480: definitions; rather, it must be defined following each
1481: .Ic machine
1482: it is intended to be used with.
1.1 deraadt 1483: If a macro named
1484: .Ic init
1485: is defined, it is automatically executed as the last step in the
1486: auto-login process.
1487: .El
1.6 millert 1488: .Sh COMMAND LINE EDITING
1489: .Nm
1.25 aaron 1490: supports interactive command line editing, via the
1.6 millert 1491: .Xr editline 3
1492: library.
1493: It is enabled with the
1494: .Ic edit
1.9 millert 1495: command, and is enabled by default if input is from a tty.
1.6 millert 1496: Previous lines can be recalled and edited with the arrow keys,
1497: and other GNU Emacs-style editing keys may be used as well.
1498: .Pp
1499: The
1500: .Xr editline 3
1501: library is configured with a
1502: .Pa .editrc
1.42 jmc 1503: file \- refer to
1.6 millert 1504: .Xr editrc 5
1505: for more information.
1506: .Pp
1507: An extra key binding is available to
1508: .Nm
1509: to provide context sensitive command and filename completion
1510: (including remote file completion).
1511: To use this, bind a key to the
1512: .Xr editline 3
1513: command
1514: .Ic ftp-complete .
1515: By default, this is bound to the TAB key.
1.1 deraadt 1516: .Sh ENVIRONMENT
1.6 millert 1517: .Nm
1.22 aaron 1518: utilizes the following environment variables:
1.15 millert 1519: .Bl -tag -width "FTPSERVERPORT"
1.16 millert 1520: .It Ev FTPMODE
1.29 aaron 1521: Overrides the default operation mode.
1522: Recognized values are:
1.48 jmc 1523: .Pp
1524: .Bl -tag -width "passive " -offset indent -compact
1.16 millert 1525: .It passive
1.48 jmc 1526: passive mode FTP only
1.16 millert 1527: .It active
1.48 jmc 1528: active mode FTP only
1.16 millert 1529: .It auto
1530: automatic determination of passive or active (this is the default)
1531: .It gate
1532: gate-ftp mode
1533: .El
1.14 millert 1534: .It Ev FTPSERVER
1535: Host to use as gate-ftp server when
1536: .Ic gate
1537: is enabled.
1538: .It Ev FTPSERVERPORT
1539: Port to use when connecting to gate-ftp server when
1540: .Ic gate
1541: is enabled.
1542: Default is port returned by a
1543: .Fn getservbyname
1.25 aaron 1544: lookup of
1.14 millert 1545: .Dq ftpgate/tcp .
1.1 deraadt 1546: .It Ev HOME
1547: For default location of a
1548: .Pa .netrc
1549: file, if one exists.
1.9 millert 1550: .It Ev PAGER
1551: Used by
1552: .Ic page
1553: to display files.
1.1 deraadt 1554: .It Ev SHELL
1555: For default shell.
1.15 millert 1556: .It Ev TMPDIR
1557: Directory to put temporary files.
1.10 millert 1558: .It Ev ftp_proxy
1559: URL of FTP proxy to use when making FTP URL requests
1.48 jmc 1560: (if not defined, use the standard FTP protocol).
1.6 millert 1561: .It Ev http_proxy
1.54 deraadt 1562: URL of HTTP proxy to use when making HTTP or HTTPS URL requests.
1.59 pyr 1563: .It Ev http_cookies
1.60 jmc 1564: Path of a Netscape-like cookiejar file to use when making
1.59 pyr 1565: HTTP or HTTPS URL requests.
1.1 deraadt 1566: .El
1.36 jakob 1567: .Sh PORT ALLOCATION
1.38 jmc 1568: For active mode data connections,
1.36 jakob 1569: .Nm
1.42 jmc 1570: will listen to a random high TCP port.
1.36 jakob 1571: The interval of ports used are configurable using
1.38 jmc 1572: .Xr sysctl 8
1.36 jakob 1573: variables
1.42 jmc 1574: .Va net.inet.ip.porthifirst
1.36 jakob 1575: and
1.42 jmc 1576: .Va net.inet.ip.porthilast .
1.1 deraadt 1577: .Sh SEE ALSO
1.42 jmc 1578: .Xr basename 1 ,
1579: .Xr csh 1 ,
1580: .Xr more 1 ,
1581: .Xr stty 1 ,
1582: .Xr tar 1 ,
1.28 aaron 1583: .Xr tftp 1 ,
1.42 jmc 1584: .Xr editline 3 ,
1.14 millert 1585: .Xr getservbyname 3 ,
1.42 jmc 1586: .Xr popen 3 ,
1.6 millert 1587: .Xr editrc 5 ,
1.14 millert 1588: .Xr services 5 ,
1.34 beck 1589: .Xr ftp-proxy 8 ,
1.1 deraadt 1590: .Xr ftpd 8
1591: .Sh HISTORY
1592: The
1.6 millert 1593: .Nm
1.1 deraadt 1594: command appeared in
1595: .Bx 4.2 .
1596: .Sh BUGS
1597: Correct execution of many commands depends upon proper behavior
1598: by the remote server.
1599: .Pp
1600: An error in the treatment of carriage returns
1601: in the
1602: .Bx 4.2
1.22 aaron 1603: ASCII-mode transfer code
1.1 deraadt 1604: has been corrected.
1605: This correction may result in incorrect transfers of binary files
1606: to and from
1607: .Bx 4.2
1.22 aaron 1608: servers using the ASCII type.
1.1 deraadt 1609: Avoid this problem by using the binary image type.