1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
|
.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
. if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "Net::FTP 3perl"
.TH Net::FTP 3perl "2023-11-25" "perl v5.36.0" "Perl Programmers Reference Guide"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
Net::FTP \- FTP Client class
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\& use Net::FTP;
\&
\& $ftp = Net::FTP\->new("some.host.name", Debug => 0)
\& or die "Cannot connect to some.host.name: $@";
\&
\& $ftp\->login("anonymous",\*(Aq\-anonymous@\*(Aq)
\& or die "Cannot login ", $ftp\->message;
\&
\& $ftp\->cwd("/pub")
\& or die "Cannot change working directory ", $ftp\->message;
\&
\& $ftp\->get("that.file")
\& or die "get failed ", $ftp\->message;
\&
\& $ftp\->quit;
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
\&\f(CW\*(C`Net::FTP\*(C'\fR is a class implementing a simple \s-1FTP\s0 client in Perl as
described in \s-1RFC959.\s0 It provides wrappers for the commonly used subset of the
\&\s-1RFC959\s0 commands.
If IO::Socket::IP or IO::Socket::INET6 is installed it also provides
support for IPv6 as defined in \s-1RFC2428.\s0
And with IO::Socket::SSL installed it provides support for implicit \s-1FTPS\s0
and explicit \s-1FTPS\s0 as defined in \s-1RFC4217.\s0
.PP
The Net::FTP class is a subclass of Net::Cmd and (depending on avaibility) of
IO::Socket::IP, IO::Socket::INET6 or IO::Socket::INET.
.SS "Overview"
.IX Subsection "Overview"
\&\s-1FTP\s0 stands for File Transfer Protocol. It is a way of transferring
files between networked machines. The protocol defines a client
(whose commands are provided by this module) and a server (not
implemented in this module). Communication is always initiated by the
client, and the server responds with a message and a status code (and
sometimes with data).
.PP
The \s-1FTP\s0 protocol allows files to be sent to or fetched from the
server. Each transfer involves a \fBlocal file\fR (on the client) and a
\&\fBremote file\fR (on the server). In this module, the same file name
will be used for both local and remote if only one is specified. This
means that transferring remote file \f(CW\*(C`/path/to/file\*(C'\fR will try to put
that file in \f(CW\*(C`/path/to/file\*(C'\fR locally, unless you specify a local file
name.
.PP
The protocol also defines several standard \fBtranslations\fR which the
file can undergo during transfer. These are \s-1ASCII, EBCDIC,\s0 binary,
and byte. \s-1ASCII\s0 is the default type, and indicates that the sender of
files will translate the ends of lines to a standard representation
which the receiver will then translate back into their local
representation. \s-1EBCDIC\s0 indicates the file being transferred is in
\&\s-1EBCDIC\s0 format. Binary (also known as image) format sends the data as
a contiguous bit stream. Byte format transfers the data as bytes, the
values of which remain the same regardless of differences in byte size
between the two machines (in theory \- in practice you should only use
this if you really know what you're doing). This class does not support
the \s-1EBCDIC\s0 or byte formats, and will default to binary instead if they
are attempted.
.SS "Class Methods"
.IX Subsection "Class Methods"
.ie n .IP """new([$host][, %options])""" 4
.el .IP "\f(CWnew([$host][, %options])\fR" 4
.IX Item "new([$host][, %options])"
This is the constructor for a new Net::FTP object. \f(CW$host\fR is the
name of the remote host to which an \s-1FTP\s0 connection is required.
.Sp
\&\f(CW$host\fR is optional. If \f(CW$host\fR is not given then it may instead be
passed as the \f(CW\*(C`Host\*(C'\fR option described below.
.Sp
\&\f(CW%options\fR are passed in a hash like fashion, using key and value pairs.
Possible options are:
.Sp
\&\fBHost\fR \- \s-1FTP\s0 host to connect to. It may be a single scalar, as defined for
the \f(CW\*(C`PeerAddr\*(C'\fR option in IO::Socket::INET, or a reference to
an array with hosts to try in turn. The \*(L"host\*(R" method will return the value
which was used to connect to the host.
.Sp
\&\fBFirewall\fR \- The name of a machine which acts as an \s-1FTP\s0 firewall. This can be
overridden by an environment variable \f(CW\*(C`FTP_FIREWALL\*(C'\fR. If specified, and the
given host cannot be directly connected to, then the
connection is made to the firewall machine and the string \f(CW@hostname\fR is
appended to the login identifier. This kind of setup is also referred to
as an ftp proxy.
.Sp
\&\fBFirewallType\fR \- The type of firewall running on the machine indicated by
\&\fBFirewall\fR. This can be overridden by an environment variable
\&\f(CW\*(C`FTP_FIREWALL_TYPE\*(C'\fR. For a list of permissible types, see the description of
ftp_firewall_type in Net::Config.
.Sp
\&\fBBlockSize\fR \- This is the block size that Net::FTP will use when doing
transfers. (defaults to 10240)
.Sp
\&\fBPort\fR \- The port number to connect to on the remote machine for the
\&\s-1FTP\s0 connection
.Sp
\&\fB\s-1SSL\s0\fR \- If the connection should be done from start with \s-1SSL,\s0 contrary to later
upgrade with \f(CW\*(C`starttls\*(C'\fR.
.Sp
\&\fBSSL_*\fR \- \s-1SSL\s0 arguments which will be applied when upgrading the control or
data connection to \s-1SSL.\s0 You can use \s-1SSL\s0 arguments as documented in
IO::Socket::SSL, but it will usually use the right arguments already.
.Sp
\&\fBTimeout\fR \- Set a timeout value in seconds (defaults to 120)
.Sp
\&\fBDebug\fR \- debug level (see the debug method in Net::Cmd)
.Sp
\&\fBPassive\fR \- If set to a non-zero value then all data transfers will
be done using passive mode. If set to zero then data transfers will be
done using active mode. If the machine is connected to the Internet
directly, both passive and active mode should work equally well.
Behind most firewall and \s-1NAT\s0 configurations passive mode has a better
chance of working. However, in some rare firewall configurations,
active mode actually works when passive mode doesn't. Some really old
\&\s-1FTP\s0 servers might not implement passive transfers. If not specified,
then the transfer mode is set by the environment variable
\&\f(CW\*(C`FTP_PASSIVE\*(C'\fR or if that one is not set by the settings done by the
\&\fIlibnetcfg\fR utility. If none of these apply then passive mode is
used.
.Sp
\&\fBHash\fR \- If given a reference to a file handle (e.g., \f(CW\*(C`\e*STDERR\*(C'\fR),
print hash marks (#) on that filehandle every 1024 bytes. This
simply invokes the \f(CW\*(C`hash()\*(C'\fR method for you, so that hash marks
are displayed for all transfers. You can, of course, call \f(CW\*(C`hash()\*(C'\fR
explicitly whenever you'd like.
.Sp
\&\fBLocalAddr\fR \- Local address to use for all socket connections. This
argument will be passed to the super class, i.e. IO::Socket::INET
or IO::Socket::IP.
.Sp
\&\fBDomain\fR \- Domain to use, i.e. \s-1AF_INET\s0 or \s-1AF_INET6.\s0 This
argument will be passed to the IO::Socket super class.
This can be used to enforce IPv4 even with IO::Socket::IP
which would default to IPv6.
\&\fBFamily\fR is accepted as alternative name for \fBDomain\fR.
.Sp
If the constructor fails undef will be returned and an error message will
be in $@
.SS "Object Methods"
.IX Subsection "Object Methods"
Unless otherwise stated all methods return either a \fItrue\fR or \fIfalse\fR
value, with \fItrue\fR meaning that the operation was a success. When a method
states that it returns a value, failure will be returned as \fIundef\fR or an
empty list.
.PP
\&\f(CW\*(C`Net::FTP\*(C'\fR inherits from \f(CW\*(C`Net::Cmd\*(C'\fR so methods defined in \f(CW\*(C`Net::Cmd\*(C'\fR may
be used to send commands to the remote \s-1FTP\s0 server in addition to the methods
documented here.
.ie n .IP """login([$login[, $password[, $account]]])""" 4
.el .IP "\f(CWlogin([$login[, $password[, $account]]])\fR" 4
.IX Item "login([$login[, $password[, $account]]])"
Log into the remote \s-1FTP\s0 server with the given login information. If
no arguments are given then the \f(CW\*(C`Net::FTP\*(C'\fR uses the \f(CW\*(C`Net::Netrc\*(C'\fR
package to lookup the login information for the connected host.
If no information is found then a login of \fIanonymous\fR is used.
If no password is given and the login is \fIanonymous\fR then \fIanonymous@\fR
will be used for password.
.Sp
If the connection is via a firewall then the \f(CW\*(C`authorize\*(C'\fR method will
be called with no arguments.
.ie n .IP """starttls()""" 4
.el .IP "\f(CWstarttls()\fR" 4
.IX Item "starttls()"
Upgrade existing plain connection to \s-1SSL.\s0
The \s-1SSL\s0 arguments have to be given in \f(CW\*(C`new\*(C'\fR already because they are needed for
data connections too.
.ie n .IP """stoptls()""" 4
.el .IP "\f(CWstoptls()\fR" 4
.IX Item "stoptls()"
Downgrade existing \s-1SSL\s0 connection back to plain.
This is needed to work with some \s-1FTP\s0 helpers at firewalls, which need to see the
\&\s-1PORT\s0 and \s-1PASV\s0 commands and responses to dynamically open the necessary ports.
In this case \f(CW\*(C`starttls\*(C'\fR is usually only done to protect the authorization.
.ie n .IP """prot($level)""" 4
.el .IP "\f(CWprot($level)\fR" 4
.IX Item "prot($level)"
Set what type of data channel protection the client and server will be using.
Only \f(CW$level\fRs \*(L"C\*(R" (clear) and \*(L"P\*(R" (private) are supported.
.ie n .IP """host()""" 4
.el .IP "\f(CWhost()\fR" 4
.IX Item "host()"
Returns the value used by the constructor, and passed to the IO::Socket super
class to connect to the host.
.ie n .IP """account($acct)""" 4
.el .IP "\f(CWaccount($acct)\fR" 4
.IX Item "account($acct)"
Set a string identifying the user's account.
.ie n .IP """authorize([$auth[, $resp]])""" 4
.el .IP "\f(CWauthorize([$auth[, $resp]])\fR" 4
.IX Item "authorize([$auth[, $resp]])"
This is a protocol used by some firewall ftp proxies. It is used
to authorise the user to send data out. If both arguments are not specified
then \f(CW\*(C`authorize\*(C'\fR uses \f(CW\*(C`Net::Netrc\*(C'\fR to do a lookup.
.ie n .IP """site($args)""" 4
.el .IP "\f(CWsite($args)\fR" 4
.IX Item "site($args)"
Send a \s-1SITE\s0 command to the remote server and wait for a response.
.Sp
Returns most significant digit of the response code.
.ie n .IP """ascii()""" 4
.el .IP "\f(CWascii()\fR" 4
.IX Item "ascii()"
Transfer file in \s-1ASCII. CRLF\s0 translation will be done if required
.ie n .IP """binary()""" 4
.el .IP "\f(CWbinary()\fR" 4
.IX Item "binary()"
Transfer file in binary mode. No transformation will be done.
.Sp
\&\fBHint\fR: If both server and client machines use the same line ending for
text files, then it will be faster to transfer all files in binary mode.
.ie n .IP """type([$type])""" 4
.el .IP "\f(CWtype([$type])\fR" 4
.IX Item "type([$type])"
Set or get if files will be transferred in \s-1ASCII\s0 or binary mode.
.ie n .IP """rename($oldname, $newname)""" 4
.el .IP "\f(CWrename($oldname, $newname)\fR" 4
.IX Item "rename($oldname, $newname)"
Rename a file on the remote \s-1FTP\s0 server from \f(CW$oldname\fR to \f(CW$newname\fR. This
is done by sending the \s-1RNFR\s0 and \s-1RNTO\s0 commands.
.ie n .IP """delete($filename)""" 4
.el .IP "\f(CWdelete($filename)\fR" 4
.IX Item "delete($filename)"
Send a request to the server to delete \f(CW$filename\fR.
.ie n .IP """cwd([$dir])""" 4
.el .IP "\f(CWcwd([$dir])\fR" 4
.IX Item "cwd([$dir])"
Attempt to change directory to the directory given in \f(CW$dir\fR. If
\&\f(CW$dir\fR is \f(CW".."\fR, the \s-1FTP\s0 \f(CW\*(C`CDUP\*(C'\fR command is used to attempt to
move up one directory. If no directory is given then an attempt is made
to change the directory to the root directory.
.ie n .IP """cdup()""" 4
.el .IP "\f(CWcdup()\fR" 4
.IX Item "cdup()"
Change directory to the parent of the current directory.
.ie n .IP """passive([$passive])""" 4
.el .IP "\f(CWpassive([$passive])\fR" 4
.IX Item "passive([$passive])"
Set or get if data connections will be initiated in passive mode.
.ie n .IP """pwd()""" 4
.el .IP "\f(CWpwd()\fR" 4
.IX Item "pwd()"
Returns the full pathname of the current directory.
.ie n .IP """restart($where)""" 4
.el .IP "\f(CWrestart($where)\fR" 4
.IX Item "restart($where)"
Set the byte offset at which to begin the next data transfer. Net::FTP simply
records this value and uses it when during the next data transfer. For this
reason this method will not return an error, but setting it may cause
a subsequent data transfer to fail.
.ie n .IP """rmdir($dir[, $recurse])""" 4
.el .IP "\f(CWrmdir($dir[, $recurse])\fR" 4
.IX Item "rmdir($dir[, $recurse])"
Remove the directory with the name \f(CW$dir\fR. If \f(CW$recurse\fR is \fItrue\fR then
\&\f(CW\*(C`rmdir\*(C'\fR will attempt to delete everything inside the directory.
.ie n .IP """mkdir($dir[, $recurse])""" 4
.el .IP "\f(CWmkdir($dir[, $recurse])\fR" 4
.IX Item "mkdir($dir[, $recurse])"
Create a new directory with the name \f(CW$dir\fR. If \f(CW$recurse\fR is \fItrue\fR then
\&\f(CW\*(C`mkdir\*(C'\fR will attempt to create all the directories in the given path.
.Sp
Returns the full pathname to the new directory.
.ie n .IP """alloc($size[, $record_size])""" 4
.el .IP "\f(CWalloc($size[, $record_size])\fR" 4
.IX Item "alloc($size[, $record_size])"
The alloc command allows you to give the ftp server a hint about the size
of the file about to be transferred using the \s-1ALLO\s0 ftp command. Some storage
systems use this to make intelligent decisions about how to store the file.
The \f(CW$size\fR argument represents the size of the file in bytes. The
\&\f(CW$record_size\fR argument indicates a maximum record or page size for files
sent with a record or page structure.
.Sp
The size of the file will be determined, and sent to the server
automatically for normal files so that this method need only be called if
you are transferring data from a socket, named pipe, or other stream not
associated with a normal file.
.ie n .IP """ls([$dir])""" 4
.el .IP "\f(CWls([$dir])\fR" 4
.IX Item "ls([$dir])"
Get a directory listing of \f(CW$dir\fR, or the current directory.
.Sp
In an array context, returns a list of lines returned from the server. In
a scalar context, returns a reference to a list.
.ie n .IP """dir([$dir])""" 4
.el .IP "\f(CWdir([$dir])\fR" 4
.IX Item "dir([$dir])"
Get a directory listing of \f(CW$dir\fR, or the current directory in long format.
.Sp
In an array context, returns a list of lines returned from the server. In
a scalar context, returns a reference to a list.
.ie n .IP """get($remote_file[, $local_file[, $where]])""" 4
.el .IP "\f(CWget($remote_file[, $local_file[, $where]])\fR" 4
.IX Item "get($remote_file[, $local_file[, $where]])"
Get \f(CW$remote_file\fR from the server and store locally. \f(CW$local_file\fR may be
a filename or a filehandle. If not specified, the file will be stored in
the current directory with the same leafname as the remote file.
.Sp
If \f(CW$where\fR is given then the first \f(CW$where\fR bytes of the file will
not be transferred, and the remaining bytes will be appended to
the local file if it already exists.
.Sp
Returns \f(CW$local_file\fR, or the generated local file name if \f(CW$local_file\fR
is not given. If an error was encountered undef is returned.
.ie n .IP """put($local_file[, $remote_file])""" 4
.el .IP "\f(CWput($local_file[, $remote_file])\fR" 4
.IX Item "put($local_file[, $remote_file])"
Put a file on the remote server. \f(CW$local_file\fR may be a name or a filehandle.
If \f(CW$local_file\fR is a filehandle then \f(CW$remote_file\fR must be specified. If
\&\f(CW$remote_file\fR is not specified then the file will be stored in the current
directory with the same leafname as \f(CW$local_file\fR.
.Sp
Returns \f(CW$remote_file\fR, or the generated remote filename if \f(CW$remote_file\fR
is not given.
.Sp
\&\fB\s-1NOTE\s0\fR: If for some reason the transfer does not complete and an error is
returned then the contents that had been transferred will not be remove
automatically.
.ie n .IP """put_unique($local_file[, $remote_file])""" 4
.el .IP "\f(CWput_unique($local_file[, $remote_file])\fR" 4
.IX Item "put_unique($local_file[, $remote_file])"
Same as put but uses the \f(CW\*(C`STOU\*(C'\fR command.
.Sp
Returns the name of the file on the server.
.ie n .IP """append($local_file[, $remote_file])""" 4
.el .IP "\f(CWappend($local_file[, $remote_file])\fR" 4
.IX Item "append($local_file[, $remote_file])"
Same as put but appends to the file on the remote server.
.Sp
Returns \f(CW$remote_file\fR, or the generated remote filename if \f(CW$remote_file\fR
is not given.
.ie n .IP """unique_name()""" 4
.el .IP "\f(CWunique_name()\fR" 4
.IX Item "unique_name()"
Returns the name of the last file stored on the server using the
\&\f(CW\*(C`STOU\*(C'\fR command.
.ie n .IP """mdtm($file)""" 4
.el .IP "\f(CWmdtm($file)\fR" 4
.IX Item "mdtm($file)"
Returns the \fImodification time\fR of the given file
.ie n .IP """size($file)""" 4
.el .IP "\f(CWsize($file)\fR" 4
.IX Item "size($file)"
Returns the size in bytes for the given file as stored on the remote server.
.Sp
\&\fB\s-1NOTE\s0\fR: The size reported is the size of the stored file on the remote server.
If the file is subsequently transferred from the server in \s-1ASCII\s0 mode
and the remote server and local machine have different ideas about
\&\*(L"End Of Line\*(R" then the size of file on the local machine after transfer
may be different.
.ie n .IP """supported($cmd)""" 4
.el .IP "\f(CWsupported($cmd)\fR" 4
.IX Item "supported($cmd)"
Returns \s-1TRUE\s0 if the remote server supports the given command.
.ie n .IP """hash([$filehandle_glob_ref[, $bytes_per_hash_mark]])""" 4
.el .IP "\f(CWhash([$filehandle_glob_ref[, $bytes_per_hash_mark]])\fR" 4
.IX Item "hash([$filehandle_glob_ref[, $bytes_per_hash_mark]])"
Called without parameters, or with the first argument false, hash marks
are suppressed. If the first argument is true but not a reference to a
file handle glob, then \e*STDERR is used. The second argument is the number
of bytes per hash mark printed, and defaults to 1024. In all cases the
return value is a reference to an array of two: the filehandle glob reference
and the bytes per hash mark.
.ie n .IP """feature($name)""" 4
.el .IP "\f(CWfeature($name)\fR" 4
.IX Item "feature($name)"
Determine if the server supports the specified feature. The return
value is a list of lines the server responded with to describe the
options that it supports for the given feature. If the feature is
unsupported then the empty list is returned.
.Sp
.Vb 3
\& if ($ftp\->feature( \*(AqMDTM\*(Aq )) {
\& # Do something
\& }
\&
\& if (grep { /\ebTLS\eb/ } $ftp\->feature(\*(AqAUTH\*(Aq)) {
\& # Server supports TLS
\& }
.Ve
.PP
The following methods can return different results depending on
how they are called. If the user explicitly calls either
of the \f(CW\*(C`pasv\*(C'\fR or \f(CW\*(C`port\*(C'\fR methods then these methods will
return a \fItrue\fR or \fIfalse\fR value. If the user does not
call either of these methods then the result will be a
reference to a \f(CW\*(C`Net::FTP::dataconn\*(C'\fR based object.
.ie n .IP """nlst([$dir])""" 4
.el .IP "\f(CWnlst([$dir])\fR" 4
.IX Item "nlst([$dir])"
Send an \f(CW\*(C`NLST\*(C'\fR command to the server, with an optional parameter.
.ie n .IP """list([$dir])""" 4
.el .IP "\f(CWlist([$dir])\fR" 4
.IX Item "list([$dir])"
Same as \f(CW\*(C`nlst\*(C'\fR but using the \f(CW\*(C`LIST\*(C'\fR command
.ie n .IP """retr($file)""" 4
.el .IP "\f(CWretr($file)\fR" 4
.IX Item "retr($file)"
Begin the retrieval of a file called \f(CW$file\fR from the remote server.
.ie n .IP """stor($file)""" 4
.el .IP "\f(CWstor($file)\fR" 4
.IX Item "stor($file)"
Tell the server that you wish to store a file. \f(CW$file\fR is the
name of the new file that should be created.
.ie n .IP """stou($file)""" 4
.el .IP "\f(CWstou($file)\fR" 4
.IX Item "stou($file)"
Same as \f(CW\*(C`stor\*(C'\fR but using the \f(CW\*(C`STOU\*(C'\fR command. The name of the unique
file which was created on the server will be available via the \f(CW\*(C`unique_name\*(C'\fR
method after the data connection has been closed.
.ie n .IP """appe($file)""" 4
.el .IP "\f(CWappe($file)\fR" 4
.IX Item "appe($file)"
Tell the server that we want to append some data to the end of a file
called \f(CW$file\fR. If this file does not exist then create it.
.PP
If for some reason you want to have complete control over the data connection,
this includes generating it and calling the \f(CW\*(C`response\*(C'\fR method when required,
then the user can use these methods to do so.
.PP
However calling these methods only affects the use of the methods above that
can return a data connection. They have no effect on methods \f(CW\*(C`get\*(C'\fR, \f(CW\*(C`put\*(C'\fR,
\&\f(CW\*(C`put_unique\*(C'\fR and those that do not require data connections.
.ie n .IP """port([$port])""" 4
.el .IP "\f(CWport([$port])\fR" 4
.IX Item "port([$port])"
.PD 0
.ie n .IP """eprt([$port])""" 4
.el .IP "\f(CWeprt([$port])\fR" 4
.IX Item "eprt([$port])"
.PD
Send a \f(CW\*(C`PORT\*(C'\fR (IPv4) or \f(CW\*(C`EPRT\*(C'\fR (IPv6) command to the server. If \f(CW$port\fR is
specified then it is sent to the server. If not, then a listen socket is created
and the correct information sent to the server.
.ie n .IP """pasv()""" 4
.el .IP "\f(CWpasv()\fR" 4
.IX Item "pasv()"
.PD 0
.ie n .IP """epsv()""" 4
.el .IP "\f(CWepsv()\fR" 4
.IX Item "epsv()"
.PD
Tell the server to go into passive mode (\f(CW\*(C`pasv\*(C'\fR for IPv4, \f(CW\*(C`epsv\*(C'\fR for IPv6).
Returns the text that represents the port on which the server is listening, this
text is in a suitable form to send to another ftp server using the \f(CW\*(C`port\*(C'\fR or
\&\f(CW\*(C`eprt\*(C'\fR method.
.PP
The following methods can be used to transfer files between two remote
servers, providing that these two servers can connect directly to each other.
.ie n .IP """pasv_xfer($src_file, $dest_server[, $dest_file ])""" 4
.el .IP "\f(CWpasv_xfer($src_file, $dest_server[, $dest_file ])\fR" 4
.IX Item "pasv_xfer($src_file, $dest_server[, $dest_file ])"
This method will do a file transfer between two remote ftp servers. If
\&\f(CW$dest_file\fR is omitted then the leaf name of \f(CW$src_file\fR will be used.
.ie n .IP """pasv_xfer_unique($src_file, $dest_server[, $dest_file ])""" 4
.el .IP "\f(CWpasv_xfer_unique($src_file, $dest_server[, $dest_file ])\fR" 4
.IX Item "pasv_xfer_unique($src_file, $dest_server[, $dest_file ])"
Like \f(CW\*(C`pasv_xfer\*(C'\fR but the file is stored on the remote server using
the \s-1STOU\s0 command.
.ie n .IP """pasv_wait($non_pasv_server)""" 4
.el .IP "\f(CWpasv_wait($non_pasv_server)\fR" 4
.IX Item "pasv_wait($non_pasv_server)"
This method can be used to wait for a transfer to complete between a passive
server and a non-passive server. The method should be called on the passive
server with the \f(CW\*(C`Net::FTP\*(C'\fR object for the non-passive server passed as an
argument.
.ie n .IP """abort()""" 4
.el .IP "\f(CWabort()\fR" 4
.IX Item "abort()"
Abort the current data transfer.
.ie n .IP """quit()""" 4
.el .IP "\f(CWquit()\fR" 4
.IX Item "quit()"
Send the \s-1QUIT\s0 command to the remote \s-1FTP\s0 server and close the socket connection.
.SS "Methods for the Adventurous"
.IX Subsection "Methods for the Adventurous"
.ie n .IP """quot($cmd[, $args])""" 4
.el .IP "\f(CWquot($cmd[, $args])\fR" 4
.IX Item "quot($cmd[, $args])"
Send a command, that Net::FTP does not directly support, to the remote
server and wait for a response.
.Sp
Returns most significant digit of the response code.
.Sp
\&\fB\s-1WARNING\s0\fR This call should only be used on commands that do not require
data connections. Misuse of this method can hang the connection.
.ie n .IP """can_inet6()""" 4
.el .IP "\f(CWcan_inet6()\fR" 4
.IX Item "can_inet6()"
Returns whether we can use IPv6.
.ie n .IP """can_ssl()""" 4
.el .IP "\f(CWcan_ssl()\fR" 4
.IX Item "can_ssl()"
Returns whether we can use \s-1SSL.\s0
.SS "The dataconn Class"
.IX Subsection "The dataconn Class"
Some of the methods defined in \f(CW\*(C`Net::FTP\*(C'\fR return an object which will
be derived from the \f(CW\*(C`Net::FTP::dataconn\*(C'\fR class. See Net::FTP::dataconn for
more details.
.SS "Unimplemented"
.IX Subsection "Unimplemented"
The following \s-1RFC959\s0 commands have not been implemented:
.ie n .IP """SMNT""" 4
.el .IP "\f(CWSMNT\fR" 4
.IX Item "SMNT"
Mount a different file system structure without changing login or
accounting information.
.ie n .IP """HELP""" 4
.el .IP "\f(CWHELP\fR" 4
.IX Item "HELP"
Ask the server for \*(L"helpful information\*(R" (that's what the \s-1RFC\s0 says) on
the commands it accepts.
.ie n .IP """MODE""" 4
.el .IP "\f(CWMODE\fR" 4
.IX Item "MODE"
Specifies transfer mode (stream, block or compressed) for file to be
transferred.
.ie n .IP """SYST""" 4
.el .IP "\f(CWSYST\fR" 4
.IX Item "SYST"
Request remote server system identification.
.ie n .IP """STAT""" 4
.el .IP "\f(CWSTAT\fR" 4
.IX Item "STAT"
Request remote server status.
.ie n .IP """STRU""" 4
.el .IP "\f(CWSTRU\fR" 4
.IX Item "STRU"
Specifies file structure for file to be transferred.
.ie n .IP """REIN""" 4
.el .IP "\f(CWREIN\fR" 4
.IX Item "REIN"
Reinitialize the connection, flushing all I/O and account information.
.SH "EXAMPLES"
.IX Header "EXAMPLES"
For an example of the use of Net::FTP see
.IP "<https://www.csh.rit.edu/~adam/Progs/>" 4
.IX Item "<https://www.csh.rit.edu/~adam/Progs/>"
\&\f(CW\*(C`autoftp\*(C'\fR is a program that can retrieve, send, or list files via
the \s-1FTP\s0 protocol in a non-interactive manner.
.SH "EXPORTS"
.IX Header "EXPORTS"
\&\fINone\fR.
.SH "KNOWN BUGS"
.IX Header "KNOWN BUGS"
See <https://rt.cpan.org/Dist/Display.html?Status=Active&Queue=libnet>.
.SS "Reporting Bugs"
.IX Subsection "Reporting Bugs"
When reporting bugs/problems please include as much information as possible.
It may be difficult for me to reproduce the problem as almost every setup
is different.
.PP
A small script which yields the problem will probably be of help. It would
also be useful if this script was run with the extra options \f(CW\*(C`Debug => 1\*(C'\fR
passed to the constructor, and the output sent with the bug report. If you
cannot include a small script then please include a Debug trace from a
run of your program which does yield the problem.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
Net::Netrc,
Net::Cmd,
IO::Socket::SSL;
.PP
\&\fBftp\fR\|(1),
\&\fBftpd\fR\|(8);
.PP
<https://www.ietf.org/rfc/rfc959.txt>,
<https://www.ietf.org/rfc/rfc2428.txt>,
<https://www.ietf.org/rfc/rfc4217.txt>.
.SH "ACKNOWLEDGEMENTS"
.IX Header "ACKNOWLEDGEMENTS"
Henry Gabryjelski <henryg@WPI.EDU <mailto:henryg@WPI.EDU>> \- for the
suggestion of creating directories recursively.
.PP
Nathan Torkington <gnat@frii.com <mailto:gnat@frii.com>> \- for some
input on the documentation.
.PP
Roderick Schertler <roderick@gate.net <mailto:roderick@gate.net>> \- for
various inputs
.SH "AUTHOR"
.IX Header "AUTHOR"
Graham Barr <gbarr@pobox.com <mailto:gbarr@pobox.com>>.
.PP
Steve Hay <shay@cpan.org <mailto:shay@cpan.org>> is now maintaining
libnet as of version 1.22_02.
.SH "COPYRIGHT"
.IX Header "COPYRIGHT"
Copyright (C) 1995\-2004 Graham Barr. All rights reserved.
.PP
Copyright (C) 2013\-2017, 2020 Steve Hay. All rights reserved.
.SH "LICENCE"
.IX Header "LICENCE"
This module is free software; you can redistribute it and/or modify it under the
same terms as Perl itself, i.e. under the terms of either the \s-1GNU\s0 General Public
License or the Artistic License, as specified in the \fI\s-1LICENCE\s0\fR file.
.SH "VERSION"
.IX Header "VERSION"
Version 3.14
.SH "DATE"
.IX Header "DATE"
23 Dec 2020
.SH "HISTORY"
.IX Header "HISTORY"
See the \fIChanges\fR file.
|