Please enable JavaScript to view this site.

A-Shell Consolidated Reference

Updated January 2024; see History

xcall FTP2, host, user, password, localpath, hostfile, hostdir, opcode, status, port, {,emsg, privkey, passphrase }

FTP2 provides the client side of FTP and SFTP file transfers. Similar to, and mostly upward compatible with the now deprecated FTPDLX (see "Migrating..." below), FTP2 offers additional features and support for the latest security patches and protocol updates.

Parameters

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). Ignored when the privkey argument is specified.

localpath  (String)  [in]

Native file specification for the local file, whether sending or receiving. If not fully qualified, it will be treated as relative to the current local login directory. For non-wildcard GET operations, it must include the target filename and extension. See Comments below for wildcarding, and MX_FSPEC or the function Fn'FQFS$() in SOSLIB:[907,10] for converting DevPPN specs to native equivalents.

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 and deletions.

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. Table of Opcodes

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 as shown in the ASHNET Status Codes.

port  (Num)  [in]

Specifies the control port to use when connecting to the remote FTP/SFTP server. The most typical ports are 21 for FTP and 22 for SFTP, but servers are free to change them for various security and firewall-related reasons. In any case the parameter must be explicitly set.

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 (or S,0) 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

The source file specification—in localpath or hostfile, depending on the direction 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*.

When receiving files using a wildcard hostfile specification, localpath should be set to the base directory to receive the files. Setting localpath to "" will result in them being received into the local root directory, which will likely fail due to permissions.

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 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 History notes below related to XFTPF_DEL.

Debugging

In most cases, FTP2 will create a log file in the %TEMP%  (Windows) or /tmp (Linux) directories named ashnet.log which may contain useful details. The same detailed error log information will be returned in emsg on any error.

Migrating from FTPDLX

For the most part you can just change the name of the XCALL routine from FTPDLX to FTP2, but there are a few differences to watch out for:

For non-wildcard transfers, FTP2 requires a complete filespec in localpath, including the filename and extension, whereas FTPDLX accepts a directory and will copy the filename from the source.
FTP2 error messages are more like complete logs rather than the mere messages returned by FTPDLX. You may therefore need to increase the size of emsg and possibly adjust the way you display or otherwise handle them.
FTP2 ignores the debug flag (XFTPF_DEBUG or &h0080) and always writes error debugging information to the ashnet.log file (see Debugging) and to the emsg parameter.

See Also

FTPDLX (deprecated)

History

2024 January, A-Shell 7.0.1753:  The GET operation now manually replicates the file.ext from the hostfile parameter if the localpath parameter doesn't contain one, eliminating one obstacle to switching from FTPDLX to FTP2. In most cases, the file.ext defaulting is handled by the FTP/SFTP service anyway, but there are scenarios, particularly with SFTP, where FTP2 was failing due to lack of an explicit file.ext in localpath.

FTP2TIMEOUT environment variable now affects SFTP as well as FTP connections. Also, XFTPF_RMVEXT support added.

2021 December, A-Shell 6.5.1709, ASHNET 1.14.177:  FTP2TIMEOUT environment variable now affects SFTP as well as FTP connections. Also, XFTPF_RMVEXT support added.

2021 June, A-Shell 6.5.1703, ASHNET 1.4.174:  XFTPF_DEL now supports a complete filespec in hostfile. Previously it required the directory and filename to be split into hostdir and hostfile.

2019 June, A-Shell 6.5.1662:  Add opcodes XFTPF_DIR and XFTPF_RENAME.

2017 February, A-Shell 6.3.1544: FTP2 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 1.7.147:  you can now override the default timeout for FTP2 (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.

2014 February, A-Shell 6.1.1379:  Added routine to A-Shell.