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