popen

getmac.utils.popen(command, args)[source]

Execute a command with arguments and return the stdout (stderr is discarded).

Wrapper around getmac.utils.call_proc(), with checks to ensure the command exists and is executable and some debug logging. This should be used instead of getmac.utils.call_proc().

Parameters:
  • command (str) – command to run, e.g. ping or ping.exe

  • args (str) – arguments to pass to the command, or empty string if there are no arguments.

Return type:

str

Returns:

stdout from the command (stderr is discarded)

Raises:

CalledProcessError – the command failed to execute