It is useful to have both a return code and output of the command.
Add a new wrapper rc_cmd that returns both:
>>> rc_cmd('uname') (0, 'Linux') >>> >>> rc_cmd('sudo ip --json --brief link show dev noname') (1, 'Device "noname" does not exist.') >>>
It is useful to have both a return code and output of the command.
Add a new wrapper rc_cmd that returns both:
>>> rc_cmd('uname') (0, 'Linux') >>> >>> rc_cmd('sudo ip --json --brief link show dev noname') (1, 'Device "noname" does not exist.') >>>
PR https://github.com/vyos/vyos-1x/pull/1442
>>> from vyos.util import rc_cmd >>> >>> rc_cmd('uname') (0, 'Linux') >>> >>> rc_cmd('ip link show dev fake') (1, 'Device "fake" does not exist.') >>>
Ex2
>>> rc, command = rc_cmd('ip link show dev eth999') >>> >>> >>> print(rc) 1 >>> print(command) Device "eth999" does not exist. >>>