program to repetitively display command on crt
Tom Dunigan
dunigan at ornl-msr
Sat Nov 10 07:52:05 AEST 1984
/* display.c
* do screen update with given command
* usage is display [-seconds] command [commandargs]
* examples: display w or display ls -l or display -2 df
* to build, cc with -lcurses -ltermlib
*/
#include <stdio.h>
#include <curses.h>
char c;
char command[80];
FILE *p, *popen();
int interval=5; /* number of seconds to pause */
main(argc,argv)
int argc;
char **argv;
{
int row,i;
if (argc==1){printf("Usage display [-seconds] command\n");exit();}
if (**(argv+1) == '-') { /* interval specified */
if (--argc == 1){printf("Usage display [-seconds] command\n");exit();}
interval = atoi(*++argv + 1);
}
while(--argc>0){
strcat(command,*++argv);
strcat(command," ");
}
initscr();
clear();
for(;;){
move(0,0);
row=0;
p=popen(command,"r");
if (p==NULL){printf("failed\n"); exit();}
while( (c=getc(p)) != EOF){
if (c == '\n'){clrtoeol();move(++row,0);}
else addch(c);
}
pclose(p);
clrtobot();
refresh();
sleep(interval);
}
}
More information about the Comp.sources.unix
mailing list