Skip to content

Latest commit

 

History

History
48 lines (41 loc) · 1.93 KB

shell_cmds.md

File metadata and controls

48 lines (41 loc) · 1.93 KB

shell_cmds

Overview

Allows you to run mutliple commands on a remote host.

Examples

def test_fun(duthosts, rand_one_dut_hostname):
    duthost = duthosts[rand_one_dut_hostname]

    duthost.shell_cmds(cmds=["ls /home", "pwd", "touch /home/test_file.txt", "ls /home"])

Arguments

  • cmds - List of commands to be run on the remote host
    • Required: True
    • Type: List Element-Type: String
  • continue_on_fail - Whether the remote host should continue to run commands after a failed command
    • Reguired: False
    • Type: Boolean
    • Default: True
  • timeout - Specify time limit (in second) for each command. 0 means no limit.
    • Reguired: False
    • Type: Integer
    • Default: 0

Expected Output

A dictionary with results from commands run. The dictionary hierarchy is described below, with each indentation describing a sub-dictionary:

  • end - Datetime for when the commands finished running
  • cmds - the list of commands that user input.
  • start - Datetime for when the commands started running
  • delta - difference between start and end
  • results - List of dictionaries, each corresponding to the results for one of the commands run
    • stderr_lines - What was printed to stderr (split by line) during execution of command
    • stderr - What was printed to stderr (as one string) during execution of command
    • stdout_lines - What was printed to stdout (split by line) during execution of command
    • stdout - What was printed to stdout (as one string) during execution of command
    • cmd - command that user input. It's what actaully ran if timeout == 0.
    • cmd_with_timeout - command wrapped with timeout. It's what actually ran if timeout != 0.
    • rc - return code
    • timeout - time limit (in second) for each command. 0 means no limit.