13.03 - Commands

cleanup

Description: It allows killing a processus, mainly for ecosystem environment management.

EXECUTE cleanup WITH <Res:process> AS $()

Input:

    • <Res:process>: The name of the resource which references the processus to kill. (Resource of type process).

'local' 'query.shell'

What: Command to execute a command line on the local system.

EXECUTE local WITH {query<Res:query.shell>} USING $(timeout:<n>,streamlength:<n'>) AS {result<Res:Result.shell>}

Input:

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

    • <n>: integer that represents a time in milliseconds. It is the time the command execution will wait before crash.

    • <n'> integer that represents stream length (number of characters). An option "full" allows to have the entire stream. It can be define via an inline instruction : $(streamlength : ...). (streamlength property is available from 1.8.0 version).

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

Note 2: Be careful : Local process is not equivalent to a console, it only executes programs. So if you want to use it as a console, you should specified which shell you want to use in your command line. Most of time:

  • For windows, start your command line with: "cmd.exe /C" (first line)

  • For linux, start your command with: /bin/sh -c (according to the distribution this may be useless)

Note 3: As local process use the underlying OS, the TA scripts which use it are platform dependent.

Note 4: if the streamlength property is not defined here, we use the streamlength property by default (set to 300 characters).

Output:

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

Example (Linux):

DEFINE $(echo hello world) AS command.file

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

EXECUTE local WITH commandLine AS result

ASSERT result DOES contain WITH $(hello world) USING $(out)

Note: To execute several command lines, you will need to execute a batch. You must then give either the absolute path of your batch, or its relative path from your project's root in the DEFINE instruction.

Example (Windows):

LOAD command.bat AS command.file

CONVERT command.file TO query.shell AS commandLine

EXECUTE local WITH commandLine USING $(timeout:15000, streamlength:full) AS result

ASSERT result DOES contain WITH $(hello world) USING $(out)

ASSERT result DOES contain WITH $(nice day) USING $(out)

command.bat :

cmd.exe /C

echo hello world

echo have a nice day