Quote:
Originally Posted by nagileon
[...]
The funny part is that the "echo "Powering on: "$thevm" part gives me the correct VM name. But then the malformed name is injected into the rvc command.
[...]
|
AFAIK, as soon as I saw the
\e[0m escape/control sequence, I recognized it. It's a sequence that turns off special modes for some terminals. If
rvc normally expects that it's dealing with a terminal and using colorization to make distinctions between one thing and another, then at the end of its output, it would likely try to discontinue the various modes used to do the colorization.
If the control sequence is being placed in the variable, and the type of terminal ( or terminal emulation ) you are using, can understand that control sequence, then when you just echo the value, it would be interpreted by the "terminal". I strongly suspect that's why you don't see the characters when you just echo them to the "terminal".
To see if the sequence is being placed into the variable, instead of just echoing the value to the "terminal", try this command sequence:
Code:
echo "Powering on: "$thevm | od -bc
to let the so called "Octal Dump" command, show you byte by byte, what characters are stored in your
thevm variable.
I would look at the documentation for
rvc to see if there is some mode, which prevents
rvc from doing the colorization.
If that one control sequence is the only one you ever get in your
thevm variable, and you get it consistently, you can just chop it out, as we've already discussed. In fact, since you are already using
awk within your
bash script, you could just add to the
awk code to either chop off the end of the string, if you always have that single escape sequence there,
or if you get different control sequences,
awk could use regular expressions to match the various potential control sequences, and remove them, before printing the selected fields from the
rvc command output.
Cheers!