Directly on the Ubuntu terminal, I can extract the results from top
regarding a specific PID with:
top -p <pid> -n1 | awk '/<pid>/'
Where <pid>
should be substituted with a PID number.
When I am inside gVim 8.1, I try doing the same with:
:call system("top -p <pid> -n1 | awk '\/<pid>\/'")
I use the backslashes to make the forward-slashes be interpreted correctly as the /
character. However, to my surprise, I get the error:
TERM environment variable not set
I found that to be odd, since things like :call system("ps")
work perfectly.
If I try the same in terminal Vim 8.1, I get:
top: failed tty get^@
But again all sorts of variations of :call system("ps")
work well.
Why would that be the case and how could I make it work such that I retrieve the results of system("top -p <pid> -n1 | awk '\/<pid>\/'")
inside a variable like:
let myvariable = system("top -p <pid> -n1 | awk '\/<pid>\/'")