How to use Linux commands with SV/UVM – $system()

How do we use $system() and how do we access the command output in SV/UVM? If you ever need to do some Linux command straight from SystemVerilog or if you ever need to get an output of the command back to SV, you can use $system().

Vtool_How_to_use_Linux_commands_with_SV/UVM_-_$system()
Vtool_How_to_use_Linux_commands_with_SV/UVM_-_$system()

Note: Every Linux or Unix command executed by the shell script or user has an exit status. Exit status is an integer number. 0 exit status means the command was successful without any errors. The same concept applies to $system(). In order to avoid issues we can add another “if” statement to verify that the output of the “$system()” is equal to 0.