Operator FTPCommand

IBMStreams com.ibm.streamsx.inet Toolkit > com.ibm.streamsx.inet 3.4.0 > com.ibm.streamsx.inet.ftp > FTPCommand

The FTPCommand operator can run an ftp command at a remote host by using the FTP, FTPS, or SFTP protocols. Possible commands are: none, del, rm, rmdir, mkdir, rename, modificationTime, and pwd. The modificationTime is not possible in the SFTP protocol. The command string and the command arguments are received from port 0.

The FTPCommand operator must not be used inside a consistent region!

Summary

Ports
This operator has 2 input ports and 2 output ports.
Windowing
This operator does not accept any windowing configurations.
Parameters
This operator supports 13 parameters.

Required: command, host, path, protocol, username

Optional: connectionCloseMode, connectionTimeout, curlVerbose, filename, filenameTo, password, sendStatisticsOnError, transferTimeout

Metrics
This operator does not report any metrics.

Properties

Implementation
C++
Threading
Always - Operator always provides a single threaded execution context.

Input Ports

Ports (0)

This input port triggers a ftp command execution. Typically the requested command and parameters are received from stream attributes.

Properties

Ports (1)

This optional input port may be used to set/change the username and password.

Properties

Output Ports

Output Functions
GetData
rstring Result()

Get the command result string

boolean Success()

Get the command success indication.

rstring Url()

This function returns a string with the url including schema.

uint32 NoCommands()

Deprecated: Get the number of executed ftp commands(in case of rename only one is counted). Use function CommandCount() instead.

uint32 CommandCount()

Get the number of executed ftp commands(in case of rename only one is counted)

uint32 NoFailures()

Deprecated: Get the number of failed ftp commands. Use function CommandFailureCount() instead.

uint32 CommandFailureCount()

Get the number of failed ftp commands

<any T> T AsIs(T)

Return the argument unchanged.

GetError
int32 Error()

Deprecated: Get the error number. Use function ErrorCode() instead.

int32 ErrorCode()

Get the error number

rstring ErrorText()

Get the error description

rstring Url()

This function returns a string with the url including schema.

uint32 NoTransfers()

Deprecated: Get the number of executed ftp commands(in case of rename only one is counted). Use function CommandCount() instead.

uint32 CommandCount()

Get the number of executed ftp commands(in case of rename only one is counted)

uint32 NoTransferFailures()

Deprecated: Get the number of failed ftp commands. Use function CommandFailureCount() instead.

uint32 CommandFailureCount()

Get the number of failed ftp commands

<any T> T AsIs(T)

Return the argument unchanged.

Ports (0)

This mandatory port delivers command results and additional statistics information. The GetData output functions must be applied to this port.

Assignments
This port set allows any SPL expression of the correct type to be assigned to output attributes. Attributes not assigned in the output clause will be automatically assigned from the attributes of the input ports that have the same name and type. If there is no such input attribute, an error is reported at compile-time.

Properties

Ports (1)

This optional port may be used to carry error information and diagnostics. The GetError output functions may be applied to this port. If no output assignment is applied, the output stream must have a single attribute of type rstring.

Assignments
This port set allows any SPL expression of the correct type to be assigned to output attributes.

Properties

Parameters

This operator supports 13 parameters.

Required: command, host, path, protocol, username

Optional: connectionCloseMode, connectionTimeout, curlVerbose, filename, filenameTo, password, sendStatisticsOnError, transferTimeout

command

the command to be executed

Properties

connectionCloseMode

This optionally parameter controls when the closing of connection after transfer. The parameter takes one value of type ConnectionCloseMode. Default value is never.

Properties

connectionTimeout

This is the maximum time in seconds that you allow the connection to the server to take. This only limits the connection phase, once it has connected, this option is of no more use. Set to zero to switch to the default built-in connection timeout - 120 seconds. See also the transferTimeout parameter.

Properties

curlVerbose

Verbose mode for curl lib default is false. The curl information are sent stderr.

Properties

filename

The command argument / may be empty for pwd

Properties

filenameTo

The to filename for rename - must be non empty for rename command

Properties

host

Hostname or IP address of the remote host in form hostname[:port].

Properties

password

The password for the ftp user. If the operator has two input ports and this parameter is an attribute parameter it must be supplied from the second input port.

Properties

path

The path of the remote directory where the command is executed. The parameter must end with a '/'. The path should begin with '/'. In case of ftp protocols the path is relative to the home directory of the user and may depend on the server configuration. In case of ftp protocol an absolute path must start with '//'. In case of sftp the path is an absolute path. A path relative to users home directory may be entered in the form '~/'.

Properties

protocol

Protocol and encryption properties of the connection. This parameter takes one value of type Protocol

Properties

sendStatisticsOnError

If set to true, the operator sends out a statistics tuple on port 0 when the operation fails. Default value is true.

Properties

transferTimeout

This is the maximum time in seconds that you allow the libcurl transfer operation to take. Normally, name lookups can take a considerable time. Default timeout is 0 (zero) which means it never times out.

Properties

username

The ftp username. If the operator has two input ports and this parameter is an attribute parameter it must be supplied from the second input port.

Properties

Code Templates

FTPCommand-Remove

stream<rstring fileName, boolean success> ${ResultStream} as OUT = FTPCommand(${CommandStream} as IN) {
	param
		protocol : ftp;
		host : IN.host;
		path : IN.path + "/";
		filename : IN.fileName;
		command : "del";
		username : "${username}";
		password : "${password}";
	output OUT :
		success = Success();
}
      

Libraries

curl lib
Library Name: curl
FTP wrapper lib
Library Name: inettoolkit
Library Path: ../../impl/lib
Include Path: ../../impl/include