Updated February 2017; see History
xcall FTP2, host, user, password, localpath, hostfile, hostdir, opcode, status {, port, emsg, privkey, passphrase }
(Windows and Linux - see History). FTP2 supports the client side of FTP and SFTP file transfers. Similar to FTPDLX and mostly upward compatible with it, FTP2 differs in the following ways:
host (String) [in]
Specifies the name or IP address of the HOST computer you want to send files to or receive files from.
user (String) [in]
Specifies the user login name for the remote HOST. For anonymous FTP, use "anonymous"
password (String) [in]
Specifies the login password. For anonymous FTP, use your email address (e.g. myname@mydoman.com)
localpath (String) [in]
Native file specification (Windows or Linux format, depending on the platform) for the local file (whether sending or receiving). If no directory specified, the current login directory will be used. Note: you may want to use MIAMEX, MX_FSPEC to translate an AMOS directory specification to a PC version. Otherwise, beware of case sensitivity under Linux. See Comments below for wildcarding.
hostfile (String) [in]
May be the full pathspec of the remote file, or just the filename and extension. In the former case, leave HOSTDIR blank, otherwise specify the directory in HOSTDIR. HOSTFILE is case sensitive. See Comments below for wildcarding.
hostdir (String) [in]
If not blank, it is prepended to the hostfile field to form the full pathspec of the remote file. hostdir is case sensitive.
opcode (Num) [in]
Note that while most of the codes apply to both FTPDLX and FTP2, some apply—as indicated—only to one or the other.
Symbol |
Value |
Description |
XFTPF_GET |
&h000000 |
Transfer from server to client PC. |
XFTPF_PUT |
&h000001 |
Transfer from client PC to server. |
XFTPF_ASCII |
&h000002 |
ASCII transfer mode. Note that some FTP servers will ignore the ASCII option as a security precaution. |
XFTPF_PASSIVE |
&h000020 |
Passive transfer mode. This is often needed to get past firewall restrictions. |
XFTPF_SFTP |
&h000100 |
Use SFTP protocol instead of FTP. This requires a SSH2 service on the server side, typically at port 22. |
XFTPF_VERSION2 |
&h010000 |
Request FTP2. FTPSYNC mode only. |
XFTPF_KEEPOPEN |
&h020000 |
Keep connection open. Automatically set for FTP2. |
XFTPF_REUSE |
&h040000 |
Reuse previous connection if available. Automatically set for FTP2. |
XFTPF_CLOSE |
&h080000 |
Close connection, no transfer. Automatically set for FTP2. |
XFTPF_DEL |
&h100000 |
Remote delete. Automatically set for FTP2. |
XFTPF_RECURSE |
&h00200000 |
recurse subdirs, with wildcards. |
The following are mutually exclusive (SFTP only); M=missing, N=newer, S=size. | ||
XFTPF_SYNC_ALL |
&h00000000 |
All matching files. |
XFTPF_SYNC_M |
&h01000000 |
All files that don't exist in destination. |
XFTPF_SYNC_MN |
&h02000000 |
All files that don't exist in destination, or are newer in source. |
XFTPF_SYNC_N |
&h03000000 |
Only files that exist in both places but are newer in source. |
XFTPF_SYNC_MS |
&h04000000 |
All files that don't exist in destination or are different size. |
XFTPF_SYNC_MNS |
&h05000000 |
All files that don't exist in destination or are different size or newer. |
XFTPF_SYNC_DELM |
&h0F000000 |
With XFTPF_DEL, only remote files not existing locally. |
Definition file: ashell.def |
status (F,6) [out]
Return status. Greater than zero indicates success. In some cases (primarily wildcard operations with SFTP protocol), status will return the number of files actually transferred or deleted. Negative values indicate errors; see table below.
port (Num) [in]
Specifies the control port to connect to the FTP server on. Default is 21 for FTP and 22 for SFTP.
emsg (String) [out]
Will contain a debug trace in the case of an error. Since this can be lengthy, you should provide a string of at least 1500 bytes to contain it all. In the case of wildcard transfers or deletions using the SFTP protocol, on success it will contain a list of the files actually transferred or deleted.
privkey (String) [in])
contains the filespec of private key file in OpenSSH format. If specified and non-blank, FTPDLX will use public/private key authentication rather than standard password authentication.
passphrase (String) [in]
is the passphrase for the private key. May be omitted if the private key is not passphrase-protected.
Comments
Nothing is displayed during the transfer, unless an error occurs and opcode +16 is not specified .
The source file specification (in localpath or hostfile, depending on the directory of the transfer) may contain the "*" wildcard. For example, "/vm/miame/dsk0/007006/*.dat", or "/vm/miame/dsk0/007006/ab*", or even "c:\vm\miame\dsk0\007006\cyxz*.d*"
FTP2 is used in ZTXFER and ATSYNC if the /2 switch is specified.
The XFTPF_SYNC opcode options apply only to the SFTP protocol (XTFPF_SFTP), and only come into play when a wildcard is specified in the relevant source argument and the destination is just a directory. The wildcard source argument acts as the first level of filtering on files to be transferred, with further filtering determined by the XFTPF_SYNC_xxx options.
Note that unlike most of the XFTPF_xxx flags, which are coded as unique bits and thus could theoretically be combined in any way, provided it makes functional sense, the XFTPF_SYNC_xxx options are all mutually exclusive—i.e., choose only one. Also note that XFTPF_SYNC_DELM only applies in conjunction with XFTPF_DEL.
When doing wildcard transfers or remote deletions, the status parameter now returns on success the number of files transferred or deleted, rather than just zero. Also, the emsg parameter in that case will contain a list of the files transferred or deleted, delimited by line breaks.
See program FTPTST in SOSLIB:[907,33]
History
2017 February, A-Shell 6.3.1544: FTP2.SBR now exposed to Linux via libashnet.so.1.9.157. Wildcards are now supported in the SFTP protocol; previously they were only supported for the FTP protocol. New opcode options added.
2015 April, A-Shell 6.1.1406: Added FTP/SFTP remote delete.
2015 March, A-Shell 6.1.1405: ASHNET.DLL 1.7(147) refinement: you can now override the default timeout for FTP2.SBR (60 seconds) by defining the environment variable FTP2TIMEOUT as the desired timeout in seconds, e.g. .SETENV FTP2TIMEOUT=10. Note that this is implemented entirely in ASHNET.DLL.
2014 February, A-Shell 6.1.1379: Added routine to A-Shell