I am currently running this script in Windows 7.
So, I have a program that is meant to color-code output from another command (mkmk) and tally up varying numbers of errors and other notable stats, etc. So right now, it starts as a batch file which
- Turns off echo
- Sets some color values to variables
- Calls the mkmk command and the awk script together
The awk script then parses line by line, and calls a function which then calls an exe that performs the Colorizing. Works like follows:
/: error/ {
CntError++ ;
TraError[CntError] = $0;
colorf(cErrorDcb,$0) ;
next
}
function colorf(fg, str ) {
if ( Couleur < 1 )
{
printf("%s\n",str);
}
else
{
if ( System == "UNIX" )
{
printf("%s%s%s%s\n",fg,bg,str,NORMAL);
}
else
{
system("Colorize.exe /c:" fg " \"" str "\"");
printf("\n");
}
}
}
So, everything works, EXCEPT that every time system("Colorize.exe") is called (a lot), the command is outputted in the terminal and clutters up the output. It doesn't appear to be affected by the @echo off command in my batch file since it is called inside the awk script. Is there anyway to hide only these system commands but keep the rest of my awk output?
I have no idea what the magical Windows incantations are to control what displays on the terminal but in general instead of calling
system()
and letting the command it calls produce it's own output that's getting mixed in with the awk output, usegetline
to read the result of the call to populate a variable and then print that from awk. Something like this:I got rid of all of the useless semi-colons too.
Best advice - get
cygwin
!