08.04 - Commands

'execute' 'query.shell' on 'ssh'

What: Command to execute a command line over SSH.

EXECUTE execute WITH {query<Res:query.shell>} ON {<Tar:ssh.target>} AS {result<Res:Result.shell>} [ USING $(timeout : <n>) ]

Input:

    • query<Res:query.shell>: The name of the resource which references a file which includes one or several shell command lines.(Resource of category query.shell)

    • <Tar:ssh.target>: The name (in the context) of the SSH server to use. (Target of category ssh.target)

    • <n>: integer that represents a time in milliseconds. It's the time to wait before the command execution passes in timeout.It can be define via an inline instruction: $(timeout : ...)

Note: if the timeout property is not defined here, we use the timeout property of the resource query.shell (set to 5s by default).

Output:

    • result<Res:result.shell>: The name of the resource which contains the shell commands result. (Resource of category result.shell)

Example:

LOAD shell/shell_command.txt AS command.file

CONVERT command.file TO query.shell USING $(timeout:15000) AS commandLine

EXECUTE execute WITH commandLine ON ssh_server AS result

'put' 'file' on 'SFTP'

What: This command permits to put a file on a SFTP server.

EXECUTE put WITH {<Res:file>} ON {<Tar:ssh.target>} AS $() USING $(remotepath : <distantPath> )

Input:

    • <Res:file>: The name of the resource which references the file to put on the SFTP server. (Resource of category file)

    • <Tar:ssh.target>: The name (in the context) of the SFTP server to use. (Target of category ssh.target)

    • <distantPath>: It corresponds to the file path on the SFTP server, relatively to the home directory.

Remark: If in the path 'distantPath' some directories don't exist on the server so they are created.

Example:

LOAD path/toto.xml AS toto

EXECUTE put WITH toto ON SFTP-server USING $(remotepath : toto.xml) AS $()

'get' 'file' on 'SFTP'

What: This command permits to get a file from a SFTP server.

EXECUTE get WITH $() ON {<Tar:ssh.target>} AS {result<Res:file>} USING $(remotepath : <distantPath> )

Input:

    • <Tar:ssh.target>: The name (in the context) of the SFTP server to use. (Target of category ssh.target)

    • <distantPath>: It corresponds to the file path on the SFTP server, relatively to the home directory of the file you want to get.

Output:

    • result<Res:file>: The name of the resource which references the file you get from the SFTP server. (Resource of category file)

Example:

EXECUTE get WITH $() ON SFTP-server USING $(remotepath :sample.zip) AS zip

'delete' 'file' on 'SFTP'

What: This command permits to delete a file on a SFTP server.

EXECUTE delete WITH $() ON {<Tar:ssh.target>} AS $() USING $(remotepath : <distantPath> [,failIfDoesNotExist : false])

Input:

    • <Tar:ssh.target>: The name (in the context) of the SFTP server to use. (Target of category ssh.target)

    • <distantPath>: It corresponds to the file path on the SFTP server, relatively to the home directory of the file you want to delete.

    • 'failIfDoesNotExist: false': It allows to specify to Squash-TA that the test must not fail if the resource we're trying to delete doesn't exist.

Remarks:

    • DistantPath can indicate a file OR a directory.To represent a directory, the path should end with the character '/'.

    • The suppression of a directory is recursive: suppression of all sub-directories and files.

Example:

EXECUTE delete WITH $() ON SFTP-server USING $( remotepath : path/to/myfile.txt, failIfDoesNotExist: false) AS $()