I am looking for a way to execute a terminal command and get the colored output of it. In that below post, they discuss how to get the output of an executed command which is partially what I need.
But the thing is terminal will not output with ANSI color codes, which as I understand it, programs know if they output to the terminal or not so they give a colored output when printing to the terminal and non-colored for else. Even though some commands support forced-colored outputs (like grep --color=auto
, ls --color
) not all of them do.
I also tried the command script
which is said it saves colors but did not work for me.
How do I execute a command and get the output of the command within C++ using POSIX?