Page MenuHomeVyOS Platform

vyos.utill add new wrapper "rc_cmd" to get the return code and output
Closed, ResolvedPublicFEATURE REQUEST


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.')


Difficulty level
Normal (likely a few hours)
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Feature (new functionality)

Event Timeline

Viacheslav changed the subtype of this task from "Bug" to "Feature Request".Jul 28 2022, 10:57 PM


>>> from vyos.util import rc_cmd
>>> rc_cmd('uname')
(0, 'Linux')
>>> rc_cmd('ip link show dev fake')
(1, 'Device "fake" does not exist.')


>>> rc, command = rc_cmd('ip link show dev eth999')
>>> print(rc)
>>> print(command)
Device "eth999" does not exist.
Viacheslav renamed this task from vyos.utill add new wrapper "rc_cmd" to get te return code and output to vyos.utill add new wrapper "rc_cmd" to get the return code and output.Jul 28 2022, 11:21 PM
Viacheslav changed the task status from Open to In progress.Jul 28 2022, 11:54 PM
Viacheslav claimed this task.
Viacheslav moved this task from Need Triage to Finished on the VyOS 1.4 Sagitta board.