home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume11 / watcher / part01 / doit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-09-27  |  1.0 KB  |  49 lines

  1. /*
  2.    doit: here is where the real purpose of the program is actually
  3.    carried out.  
  4.  
  5.     for each command, run it and look for problems.
  6.     write results from this run back out.
  7.  
  8.    need to change from popen to ps_open.
  9.  
  10.    Kenneth Ingham
  11.  
  12.    Copyright (C) 1987 The University of New Mexico
  13. */
  14.  
  15. #include "defs.h"
  16.  
  17. doit()
  18. {
  19.     extern struct cmd_st *clist;
  20.     extern int vflag;
  21.     extern int cmd_ok;
  22.     extern FILE *hf;
  23.  
  24.     char line[MAX_STR];
  25.     struct cmd_st *p;
  26.     struct old_cmd_st *prev_results, *find_prev_cmd();
  27.     FILE *ps, *popen();
  28.  
  29.     /* run commands */
  30.     for (p=clist; p != NULL; p=p->next) {
  31.         cmd_ok = True;
  32.         if (vflag)
  33.             printf("Executing: '%s'\n\n", p->pipeline);
  34.         if (p->key.rel_fmt != NULL)
  35.             fprintf(hf, "%s\n", p->pipeline);
  36.         /* get prev results for comparison */
  37.         prev_results = find_prev_cmd(p->pipeline);
  38.         ps = popen(p->pipeline, "r");
  39.         while (fgets(line, MAX_STR, ps) != NULL) {
  40.             line[strlen(line)-1] = '\0';
  41.             if (vflag)
  42.                 printf("  Read: '%s'\n",line);
  43.             checkline(p, line, prev_results);
  44.         }
  45.         if (!cmd_ok)
  46.             printf("\n");
  47.     }
  48. }
  49.