Afloyd.136 net.sources utcsrgv!utzoo!decvax!duke!harpo!floyd!trb Thu Mar 25 14:04:22 1982 upd.c A screen updating program Please let me know if you have better ideas. -Andy ---------- /* * cc upd.c -lcurses -ltermcap -o upd * * upd.c - popen a process and use its output to update the screen * argv[1] is popen'ed so quote your command if it's more than one arg. * argv[2] is number of seconds to sleep between cycles. * Andy Tannenbaum WECo/BTL Whippany, NJ */ #include #include /* 6*1024 is more than 66*80 */ #define BUFSIZE 6*1024 FILE *pp; /* popen pointer */ char buf[BUFSIZE]; char tbuf[128]; long larg; main(argc,argv) int argc; char **argv; { extern char *CD; int i,n,sleeptime; /* sleep for sleeptime seconds between cycles */ sleeptime = (argc > 1) ? atol(argv[2]) : 1; initscr(); for(;;){ #ifdef VMUNIX /* redraw whole screen when user types a newline */ /* can be done on UNIX 3.0 too, but I don't */ ioctl(0,FIONREAD,&larg); if(larg != 0L){ read(0,tbuf,128); clear(); } #endif /* if popen fails we're hurting, so break */ if((pp=popen(argv[1],"r")) == EOF)exit(1); n=fread(buf,1,BUFSIZE,pp); buf[n]=0; pclose(pp); mvaddstr(0,0,buf); refresh(); /* my curses doesn't seem to clear the rest of the screen when * data disappears from it, but it leaves the cursor down * there, so diy */ printf("%s",CD); for(i=0;i
This Usenet Oldnews Archive article may be copied and distributed freely, provided:

1. There is no money collected for the text(s) of the articles.
2. The following notice remains appended to each copy:

The Usenet Oldnews Archive: Compilation Copyright© 1981, 1996
Bruce Jones, Henry Spencer, David Wiseman.


Goto NEXT article in NET.sources Newsgroup
Return to NET.sources index
Return to the Usenet Oldnews Archive index ----------------------------------------------------------------- gopher://quux.org/ conversion by John Goerzen of http://communication.ucsd.edu/A-News/ This Usenet Oldnews Archive article may be copied and distributed freely, provided: 1. There is no money collected for the text(s) of the articles. 2. The following notice remains appended to each copy: The Usenet Oldnews Archive: Compilation Copyright (C) 1981, 1996 Bruce Jones, Henry Spencer, David Wiseman.