Local process Plugin - Execute Macros


# EXECUTE $({command_content}) LOCALLY AS {result}

What ?

This macro will execute an inline command on the local system and check if the result is a success.

Underlying instructions :

DEFINE $({command_content}) AS __command{%%rand1}
CONVERT __command{%%rand1} TO query.shell AS __commandLine{%%rand2}
EXECUTE local WITH __commandLine{%%rand2} AS {result}
ASSERT {result} IS success

> Input :

  • {command_content} : The shell command to execute, preceded by a call to the shell (“cmd.exe /C” for Windows, “/bin/sh -c” for Linux).

> Output :

  • {result} : The name of the resource which references the result of the command (result.shell type resource).

Example :

# EXECUTE $(cmd.exe /C echo “hello world”) LOCALLY AS result


# EXECUTE $({command_content}) LOCALLY AS {result} WITHIN {timeout} ms

What ?

This macro will execute an inline command on the local system, within a timeframe, and check if the result is a success.

Underlying instructions :

DEFINE $({command_content}) AS __command{%%rand1}
CONVERT __command{%%rand1} TO query.shell AS __commandLine{%%rand2} USING $(timeout:{timeout})
EXECUTE local WITH __commandLine{%%rand2} AS {result}
ASSERT {result} IS success

> Input :

  • {command_content} : The shell command to execute, preceded by a call to the shell (“cmd.exe /C” for Windows, “/bin/sh -c” for Linux).
  • {timeout} : Maximal time authorized for the command execution (in milliseconds).

> Output :

  • {result} : The name of the resource which references the result of the command (result.shell type resource).

Example :

# EXECUTE $(cmd.exe /C echo “hello world”) LOCALLY AS result WITHIN 15000 ms


# EXECUTE SCRIPT {command_content} LOCALLY AS {result}

What ?

This macro will execute a script on the local system and check if the result is a success.

Underlying instructions :

LOAD {command_content} AS __command{%%rand1}
CONVERT __command{%%rand1} TO query.shell AS __commandLine{%%rand2}
EXECUTE local WITH __commandLine{%%rand2} AS {result}
ASSERT {result} IS success

> Input :

  • {command_content} : The script file containing the shell commands to execute, preceded by a call to the shell (“cmd.exe /C” for Windows, “/bin/sh -c” for Linux).

> Output :

  • {result} : The name of the resource which references the result of the command (result.shell type resource).

Example :

# EXECUTE SCRIPT command.bat LOCALLY AS result

File to process (Windows) :

../../_images/local-process-macros-execute-3-command.png

The folder containing the resources to process :

../../_images/local-process-macros-execute-3-tree.png

SKF script :

../../_images/local-process-macros-execute-3-script.png


# EXECUTE SCRIPT {command_content} LOCALLY AS {result} WITHIN {timeout_in_seconds} s

What ?

This macro will execute a script on the local system, within a timeframe, and check if the result is a success.

Underlying instructions :

LOAD {command_content} AS __command{%%rand1}
CONVERT __command{%%rand1} TO query.shell USING $(timeout:{timeout_in_seconds}000) AS __commandLine{%%rand2}
EXECUTE local WITH __commandLine{%%rand2} AS {result}
ASSERT {result} IS success

> Input :

  • {command_content} : The script file containing the shell commands to execute, preceded by a call to the shell (“cmd.exe /C” for Windows, “/bin/sh -c” for Linux).
  • {timeout_in_seconds} : Maximal time authorized for the command execution (in seconds).

> Output :

  • {result} : The name of the resource which references the result of the command (result.shell type resource).

Example :

# EXECUTE SCRIPT command.bat LOCALLY AS result WITHIN 5 s

File to process (Windows) :

../../_images/local-process-macros-execute-3-command.png

The folder containing the resources to process :

../../_images/local-process-macros-execute-3-tree.png

SKF script :

../../_images/local-process-macros-execute-4-script.png


# EXECUTE SCRIPT {command_content} LOCALLY AS {result} WITH STREAMLENGTH {length}

What ?

This macro will execute a script on the local system, with the length of the stream specified, and check if the result is a success.

Underlying instructions :

LOAD {command_content} AS __command{%%rand1}
CONVERT __command{%%rand1} TO query.shell USING $(streamlength:{length}) AS __commandLine{%%rand2}
EXECUTE local WITH __commandLine{%%rand2}  AS {result}
ASSERT {result} IS success

> Input :

  • {command_content} : The script file containing the shell commands to execute, preceded by a call to the shell (“cmd.exe /C” for Windows, “/bin/sh -c” for Linux).
  • {length} : An integer that represents stream length (number of characters). Specifying “full” allows to have the entire stream.

> Output :

  • {result} : The name of the resource which references the result of the command (result.shell type resource).

Example :

# EXECUTE SCRIPT command.bat LOCALLY AS result WITH STREAMLENGTH 200

File to process (Windows), with an error :

../../_images/local-process-macros-execute-5-command.png

The folder containing the resources to process :

../../_images/local-process-macros-execute-3-tree.png

SKF script :

../../_images/local-process-macros-execute-5-script.png

Warning

Streamlength (with a value of n) will shorten both the STDOUT and the STDERR, keeping only the n last characters, possibly rendering the debug harder :

../../_images/local-process-macros-execute-5-error.png


# EXECUTE SCRIPT {command_content} LOCALLY AS {result} WITH STREAMLENGTH {length} WITHIN {timeout_in_seconds} s

What ?

This macro will execute a script on the local system, with the length of the stream specified and within a timeframe, and check if the result is a success.

Underlying instructions :

LOAD {command_content} AS __command{%%rand1}
CONVERT __command{%%rand1} TO query.shell USING $(timeout:{timeout_in_seconds}000, streamlength:{length}) AS __commandLine{%%rand2}
EXECUTE local WITH __commandLine{%%rand2} AS {result}
ASSERT {result} IS success

> Input :

  • {command_content} : The script file containing the shell commands to execute, preceded by a call to the shell (“cmd.exe /C” for Windows, “/bin/sh -c” for Linux).
  • {length} : An integer that represents stream length (number of characters). Specifying “full” allows to have the entire stream.
  • {timeout_in_seconds} : Maximal time authorized for the command execution (in seconds).

> Output :

  • {result} : The name of the resource which references the result of the command (result.shell type resource).

Example :

# EXECUTE SCRIPT command.bat LOCALLY AS result WITH STREAMLENGTH 200 WITHIN 5 s

File to process (Windows), with an error :

../../_images/local-process-macros-execute-5-command.png

The folder containing the resources to process :

../../_images/local-process-macros-execute-3-tree.png

SKF script :

../../_images/local-process-macros-execute-6-script.png

Warning

Streamlength (with a value of n) will shorten both the STDOUT and the STDERR, keeping only the n last characters, possibly rendering the debug harder :

../../_images/local-process-macros-execute-5-error.png