|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi
I have a program, let's call it 'toto', that generates text with color (ansi escape codes) I want to keep a log of toto's execution, and display its output with the colors in real time, so at the moment, I do (in tcsh) : toto |& tee execution.log But when I read the log with nedit for example, the color codes present in the log alter the readability of the file. I could make a script that strips the escape characters in the log file after execution, but I would prefer if the escape sequences were never written in the file, so that no user intervention is needed. I have an idea : we could pipe the output of toto to sed, but I don't know if sed is able to print the input data both on the screen (unaltered) and to a file (with escape chars removed) Do you have a little trick that could solve my problem ? Thanks to everyone and have a nice day ! Philippe |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
pmaire@gmail.com wrote:
> > I have a program, let's call it 'toto', that generates text with color > (ansi escape codes) > I want to keep a log of toto's execution, and display its output with > the colors in real time, so at the moment, I do (in tcsh) : > > toto |& tee execution.log > > But when I read the log with nedit for example, the color codes > present in the log alter the readability of the file. > I could make a script that strips the escape characters in the log > file after execution, but I would prefer if the escape sequences were > never written in the file, so that no user intervention is needed. > > I have an idea : we could pipe the output of toto to sed, but I don't > know if sed is able to print the input data both on the screen > (unaltered) and to a file (with escape chars removed) > Do you have a little trick that could solve my problem ? [bash & GNU sed] echo 123hello | sed -ne "p;s/123//w/tmp/output.txt" 123hello $ cat /tmp/output.txt hello -- Best regards | Be nice to America or they'll bring democracy to Cyrus | your country. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
pmaire@gmail.com wrote:
> > I have a program, let's call it 'toto', that generates text with color > (ansi escape codes) > I want to keep a log of toto's execution, and display its output with > the colors in real time, so at the moment, I do (in tcsh) : > > toto |& tee execution.log > > But when I read the log with nedit for example, the color codes > present in the log alter the readability of the file. > I could make a script that strips the escape characters in the log > file after execution, but I would prefer if the escape sequences were > never written in the file, so that no user intervention is needed. > > I have an idea : we could pipe the output of toto to sed, but I don't > know if sed is able to print the input data both on the screen > (unaltered) and to a file (with escape chars removed) > Do you have a little trick that could solve my problem ? [bash & GNU sed] $ echo 123hello | sed -ne "p;s/123//w/tmp/output.txt" 123hello $ cat /tmp/output.txt hello -- Best regards | Be nice to America or they'll bring democracy to Cyrus | your country. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
pmaire@gmail.com wrote:
> Hi > I have a program, let's call it 'toto', that generates text with color > (ansi escape codes) > I want to keep a log of toto's execution, and display its output with > the colors in real time, so at the moment, I do (in tcsh) : > > toto |& tee execution.log > > But when I read the log with nedit for example, the color codes > present in the log alter the readability of the file. > I could make a script that strips the escape characters in the log > file after execution, but I would prefer if the escape sequences were > never written in the file, so that no user intervention is needed. > > I have an idea : we could pipe the output of toto to sed, but I don't > know if sed is able to print the input data both on the screen > (unaltered) and to a file (with escape chars removed) > Do you have a little trick that could solve my problem ? > > Thanks to everyone and have a nice day ! > Philippe > toto | awk '{print;gsub(/[[:control:]]/,"") rint > "log";system("")}'system() flushes the buffer. In GNU awk you could use fflush(). Ed. |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Cyrus Kriticos wrote:
> > [bash & GNU sed] > > $ echo 123hello | sed -ne "p;s/123//w/tmp/output.txt" > 123hello > > $ cat /tmp/output.txt > hello sorry, does not work correct. -- Best regards | Be nice to America or they'll bring democracy to Cyrus | your country. |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
On 2007-11-06, pmaire@gmail.com <pmaire@gmail.com> wrote:
> Hi > I have a program, let's call it 'toto', that generates text with color > (ansi escape codes) > I want to keep a log of toto's execution, and display its output with > the colors in real time, so at the moment, I do (in tcsh) : > > toto |& tee execution.log > > But when I read the log with nedit for example, the color codes > present in the log alter the readability of the file. > I could make a script that strips the escape characters in the log > file after execution, but I would prefer if the escape sequences were > never written in the file, so that no user intervention is needed. > > I have an idea : we could pipe the output of toto to sed, but I don't > know if sed is able to print the input data both on the screen > (unaltered) and to a file (with escape chars removed) > Do you have a little trick that could solve my problem ? > > Thanks to everyone and have a nice day ! > Philippe > toto |& tee /dev/tty | col -b > execution.log |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
On 6 nov, 14:12, Ed Morton <mor...@lsupcaemnt.com> wrote:
> pma...@gmail.com wrote: > > Hi > > I have a program, let's call it 'toto', that generates text with color > > (ansi escape codes) > > I want to keep a log of toto's execution, and display its output with > > the colors in real time, so at the moment, I do (in tcsh) : > > > toto |& tee execution.log > > > But when I read the log with nedit for example, the color codes > > present in the log alter the readability of the file. > > I could make a script that strips the escape characters in the log > > file after execution, but I would prefer if the escape sequences were > > never written in the file, so that no user intervention is needed. > > > I have an idea : we could pipe the output of toto to sed, but I don't > > know if sed is able to print the input data both on the screen > > (unaltered) and to a file (with escape chars removed) > > Do you have a little trick that could solve my problem ? > > > Thanks to everyone and have a nice day ! > > Philippe > > toto | awk '{print;gsub(/[[:control:]]/,"") rint > "log";system("")}'> > system() flushes the buffer. In GNU awk you could use fflush(). > > Ed.- Masquer le texte des messages précédents - > > - Afficher le texte des messages précédents - Hi, thanks for your quick answer ! However, the command does not work: awk: syntax error near line 1 awk: illegal statement near line 1 Philippe |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
On 6 nov, 16:42, Bill Marcum <marcumb...@bellsouth.net> wrote:
> On 2007-11-06, pma...@gmail.com <pma...@gmail.com> wrote: > > > > > Hi > > I have a program, let's call it 'toto', that generates text with color > > (ansi escape codes) > > I want to keep a log of toto's execution, and display its output with > > the colors in real time, so at the moment, I do (in tcsh) : > > > toto |& tee execution.log > > > But when I read the log with nedit for example, the color codes > > present in the log alter the readability of the file. > > I could make a script that strips the escape characters in the log > > file after execution, but I would prefer if the escape sequences were > > never written in the file, so that no user intervention is needed. > > > I have an idea : we could pipe the output of toto to sed, but I don't > > know if sed is able to print the input data both on the screen > > (unaltered) and to a file (with escape chars removed) > > Do you have a little trick that could solve my problem ? > > > Thanks to everyone and have a nice day ! > > Philippe > > toto |& tee /dev/tty | col -b > execution.log- Masquer le texte des messages précédents - > > - Afficher le texte des messages précédents - Hi, thanks for your answer. col does not seem to work well : in my log file, I get ----- 34m1mInfo: test 0m35m1mWarning: tttiti 0m31m1mError: myerror 0mtest2 ----- However, the tee to /dev/tty is a good idea. I will try to use sed instead of col in order to strip the escape sequences. Regards Philippe |
|
![]() |
| Outils de la discussion | |
|
|