Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site dolphy.UUCP Path: utzoo!linus!philabs!cmcl2!phri!dolphy!jmg From: jmg@dolphy.UUCP (Intergalactic Psychic Police Of Uranus) Newsgroups: net.sources Subject: scan Message-ID: <11@dolphy.UUCP> Date: Sun, 6-Oct-85 18:15:20 EDT Article-I.D.: dolphy.11 Posted: Sun Oct 6 18:15:20 1985 Date-Received: Wed, 9-Oct-85 06:06:52 EDT Distribution: net Organization: Lesbian Vampires Of Sodom Corp. Lines: 167 *** amusing & useful program *** What follows is an amusing and useful program to repeatedly execute command(s) and display their output on the screen...overlaying subsequent output on preceding output...thus, you can watch something change over time. The default (expensively) is "ps -af"...so that you can watch the system change. There are all sorts of interesting variations and modifications possible...please send them to me. In releasing this (simple) source please keep my name in it. Finally, we don't have 'nroff' or 'man' macros to make a real man page. #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # README.scan # scan.c # This archive created: Sun Oct 6 18:14:36 1985 # By: Intergalactic Psychic Police Of Uranus (Lesbian Vampires Of Sodom Corp.) export PATH; PATH=/bin:$PATH echo shar: extracting "'README.scan'" '(632 characters)' if test -f 'README.scan' then echo shar: will not over-write existing file "'README.scan'" else cat << \SHAR_EOF > 'README.scan' scan [-s delay] [quoted_command_string] Scan repeats commands over and over displaying only the first screenful via curses. Thus, one can view the changes. The default command is "ps -af" and the default delay between repeats of commands in 4 seconds. Commands must be quoted, for example scan "date;ps -fu root & df" will run 'date', then the 'ps' in the background and df", wait for the 'df', display as much as will fit on the screen of the entire output, and repeat. Stop it by interrupting. A delay of zero seconds IS possible. Author: Jeffrey Greenberg (allegra!phri!dolphy!jmg), after Rusty Wright (sdcarl!rusty). SHAR_EOF fi # end of overwriting check echo shar: extracting "'scan.c'" '(1613 characters)' if test -f 'scan.c' then echo shar: will not over-write existing file "'scan.c'" else cat << \SHAR_EOF > 'scan.c' /* * scan: 'real time' screen display - by jeffrey greenberg * Copyright 1984 Jeffrey Greenberg * ALL RIGHTS RESERVED * Source given for non-profit use only! (Please give me credit & * mail me changes!) * * compile: cc scan.c -lcurses * Should run on system 5... */ #include #include int seconds; main(argc, argv) int argc; char *argv[]; { FILE *str; int intrp(); int c; int minarg; char *execstr, *getopts(); char *copyright; copyright = "Jeffrey Greenberg 1984/85 - ALL RIGHTS RESERVED"; execstr = getopts(argc,argv); initscr(); signal(2,intrp); nonl(); cbreak(); noecho(); clear(); refresh(); loop: if( (str = popen( execstr, "r")) == NULL ) panic( execstr ); move(0,0); while( (c=fgetc( str )) != EOF ) addch(c); clrtobot(); refresh(); pclose( str ); if(seconds ) sleep( seconds ); goto loop; } panic( str ) char *str; { perror( str ); cleanup(); exit(1); } intrp() { cleanup(); exit(0); } cleanup() { echo(); nl(); nocbreak(); endwin(); } char * getopts( argc, argv ) int argc; char **argv; { int option, badopt = 0; extern int optind; extern char *optarg; static char exec_default[] = {"ps -af"}; char *execstr; seconds = 4; /* default sleep time in seconds */ while( (option=getopt(argc,argv,"s:")) != EOF ) if( option == 's' ) { if( (seconds = atoi(optarg)) < 0) ++badopt; } else { ++badopt; } if( badopt ) { fprintf(stderr,"Usage: scan [-s seconds] [quoted_command_string]\n"); exit(1); } if( (argc - 1) < optind ) execstr = exec_default; else execstr = argv[optind]; return execstr; } SHAR_EOF fi # end of overwriting check # End of shell archive exit 0