From ff9bdaab73cc27f2126a7d99c680f85b7c61d0bf Mon Sep 17 00:00:00 2001 From: patrick Date: Thu, 16 May 2024 15:59:02 +0200 Subject: [PATCH] Version 1.0 --- octave.c | 24 +++++++++++++++--------- t1.sh | 21 +++++++++++++++++++++ 2 files changed, 36 insertions(+), 9 deletions(-) create mode 100755 t1.sh diff --git a/octave.c b/octave.c index 52ab5ba..da1725d 100644 --- a/octave.c +++ b/octave.c @@ -635,6 +635,7 @@ void pr_encours(void) #define CHLOG "/var/log/user.log" #define CHLOGREP "/var/log/user.log|grep " #define CUT6 "|cut -d' ' -f6" +#define CUTM45 "|cut -d' ' -f1-3,6-" #define CUT7S "|cut -d' ' -f7-" #define FHISTO ".octave_history" @@ -724,22 +725,27 @@ pid_t pid; break; case 'E' : if (*(cmd+1) != '\0') printf("ignore %s\n",cmd+1); - sprintf(com,"grep '%s\\[%d\\]%s' %s",NPROG,pid,".*ERR: ",CHLOG); + sprintf(com,"grep '%s\\[%d\\]%s' %s%s",NPROG,pid,".*ERR: ", + CHLOG,CUTM45); comsh(com); break; case 'L' : if (*(cmd+1) != '\0') printf("ignore %s\n",cmd+1); - sprintf(com,"grep '%s\\[%d\\]' %s%s",NPROG,pid, - CHLOGREP,"-v 'Re[pq]. '"); + sprintf(com,"grep '%s\\[%d\\]' %s%s%s",NPROG,pid, + CHLOGREP,"-v 'Re[pq]. '",CUTM45); comsh(com); break; case 'T' : - if (*(cmd+1) != '\0') - sprintf(com,"grep '%s\\[%d\\].*%s' %s%s",NPROG,pid,cmd+1, - CHLOGREP," 'Re[pq]. '"); - else - sprintf(com,"grep '%s\\[%d\\]' %s%s",NPROG,pid, - CHLOGREP," 'Re[pq]. '"); + if (*(cmd+1) != '\0') { /* avec parametre */ + if ((*(cmd+1) == '+') && (*(cmd+2) != '\0')) { /* script + param */ + sprintf(com,"./t1.sh %d %s >.Trav%d",pid,cmd+2,pid); + comsh(com); + sprintf(com,"cat .Trav%d",pid); + } else sprintf(com,"grep '%s\\[%d\\].*%s' %s%s%s",NPROG,pid,cmd+1, + CHLOGREP," 'Re[pq]. '",CUTM45); + } else + sprintf(com,"grep '%s\\[%d\\]' %s%s%s",NPROG,pid, + CHLOGREP," 'Re[pq]. '",CUTM45); comsh(com); prInOut(); break; diff --git a/t1.sh b/t1.sh new file mode 100755 index 0000000..d0a81d2 --- /dev/null +++ b/t1.sh @@ -0,0 +1,21 @@ +#! /bin/sh + +explic () +{ + echo "Utilisation : $0 PID_OctavE mots_cles !" >&2 + exit 1 +} + +[ $# != 2 ] && explic +liste=`grep 'OctavE\['$1'\].*'$2 /var/log/user.log|grep -v ' ERR: '|grep ': Re[pq]\. '|cut -d' ' -f7|sort|uniq` +p="" +for v in $liste +do + p=$p"|"$v +done +p2=`echo $p|sed 's/|//'` +# echo '('$p2')' +grep 'OctavE\['$1'\]' /var/log/user.log|egrep '('$p2')'|cut -d' ' -f1-3,6- + + +