08.06 - Build-in shortcuts (macros)


# EXECUTE_SSH $({command_content}) ON {target} AS {result}

What: This macro will execute an inline command on a SSH server. 

# EXECUTE_SSH $({command_content}) ON {target} AS {result}
=>
DEFINE $({command_content}) AS __command{%%rand1}
CONVERT __command{%%rand1} TO query.shell AS __commandLine{%%rand2}
EXECUTE execute WITH __commandLine{%%rand2} ON {target} AS {result}
ASSERT {result} IS success

Input:

  • {target}: The name (in the context) of the SSH server to use. (Target of category ssh.target)
  • {command_content}: It corresponds to the text of the shell command to execute.
Output:
  • {result}: The name of the resource which references the result of the command.(Resource of category result.shell)

Example:

# EXECUTE_SSH $(echo "hello world") ON ssh-server AS result


# EXECUTE_SSH $({command_content}) ON {target} AS {result} WITHIN {timeout} ms

What: This macro will execute an inline command on a SSH server. 

# EXECUTE_SSH $({command_content}) ON {target} AS {result} WITHIN {timeout} ms
=>
DEFINE $({command_content}) AS __command{%%rand1}
CONVERT __command{%%rand1} TO query.shell AS __commandLine{%%rand2}
EXECUTE execute WITH __commandLine{%%rand2} ON {target} USING $(timeout:{timeout}) AS {result}
ASSERT {result} IS success

Input:

  • {target}: The name (in the context) of the SSH server to use. (Target of category ssh.target)
  • {command_content}: It corresponds to the text of the shell command to execute.
  • {timeout}: Maximal time authorized for the command execution (in milliseconds).
Output:
  • {result}: The name of the resource which references the result of the command. (Resource of category result.shell)

Example:

# EXECUTE_SSH $(echo "hello world") ON ssh-server AS result WITHIN 15000 ms


# EXECUTE_SSH_SCRIPT {script} ON {target} AS {result}

What: This macro will execute a shell script on a SSH server. 

# EXECUTE_SSH_SCRIPT {script} ON {target} AS {result}
=>

LOAD {script} AS __{%%r1}.file
CONVERT __{%%r1}.file TO file(param.relativedate) AS __{%%r2}.file
CONVERT __{%%r2}.file TO query.shell AS __{%%r3}.script
EXECUTE execute WITH __{%%r3}.script ON {target} AS {result}
ASSERT {result} IS success

Input:

  • {target}: The name (in the context) of the SSH server to use. (Target of category ssh.target)
  • {script}: It corresponds to the path of the shell script to execute.
Output :
  • {result}: The name of the resource which references the result of the command. (Resource of category result.shell)

Example:

# EXECUTE_SSH_SCRIPT shell/shell-script.txt ON ssh-server AS result


# EXECUTE_SSH_SCRIPT {script} ON {target} AS {result} WITHIN {timeout} ms

What: This macro will execute a shell script on a SSH server. 

# EXECUTE_SSH_SCRIPT {script} ON {target} AS {result} WITHIN {timeout} ms
=>

LOAD {script} AS __{%%r1}.file
CONVERT __{%%r1}.file TO file(param.relativedate) AS __{%%r2}.file
CONVERT __{%%r2}.file TO query.shell AS __{%%r3}.script
EXECUTE execute WITH __{%%r3}.script ON {target} USING $(timeout:{timeout}) AS {result}
ASSERT {result} IS success

Input:

  • {target}: The name (in the context) of the SSH server to use. (Target of category ssh.target)
  • {script}: It corresponds to the path of the shell script to execute.
  • {timeout}: Maximal time authorized for the command execution (in milliseconds)
Output :
  • {result}: The name of the resource which references the result of the command. (Resource of category result.shell)

Example:

# EXECUTE_SSH_SCRIPT shell/shell-script.txt ON ssh-server AS result WITHIN 15000 ms