[comp.sys.atari.st] shell help

depeche@quiche.cs.mcgill.ca (Sam Alan EZUST) (12/14/89)

I wrote a program in laser C which is highly interactive, and I would
like to print the output of the program. If I simply redirect the output
I can't see it, and if I don't, I can't save it.

I have gulam and Pcommand. Does anyone know how to make the program
redirect the output but still show it on the screen?
One common way some shells do it is by turning on a "log file"
which logs all input and output, and this would be the ideal
solution. Does anyone know if either Gulam or Pcommand supports
this, and if so, how to use it?


-- 
S. Alan Ezust                                   depeche@calvin.cs.mcgill.ca
McGill University Department of Computer Science - Montreal, Quebec, Canada

bobw@hpsad.HP.COM (Bob Waltenspiel) (12/15/89)

>I have gulam and Pcommand. Does anyone know how to make the program
>redirect the output but still show it on the screen?
>One common way some shells do it is by turning on a "log file"
>which logs all input and output, and this would be the ideal
>solution. Does anyone know if either Gulam or Pcommand supports
>this, and if so, how to use it?
----------

How about 'tee' of UNIX?  Takes stdin and duplicates it to a file and 
sends it to stdout.  Gosh, sounds easy enough.  I'll give it a try.

-Bob "After my last final"

bobw@hpsad.HP.COM (Bob Waltenspiel) (12/15/89)

> "After my last final"
----------

These seemed so easy, I couldn't wait.

Here's a quick tee.c source for capturing it's stdin, logging it to a
file and writing it to stdout.  I haven't tried it with my st, but
it works on my HP 360 HP-UX machine.

/******
 *
 * tee.c: log stdin to a file and write it to stdout
 *
 * Bob Waltenspiel 12/14/89
 *
 *****/

#include <stdio.h>

#define MAXLINE 500

main(argc, argv)
int argc; char *argv[];
{
	FILE *fp;
	char *str[MAXLINE];

	if ( argc == 1 ) {
		printf("tee: must specify log file.\n");
		exit(1);
	} else 	if (argc == 2) {
		if ( (fp = fopen(argv[1], "w")) == NULL ) {
			printf("tee: cannot open %s for writing.\n", argv[1]);
			exit(1);
		}
	} else if (argc == 3) {
		if ( (fp = fopen(argv[2], "a")) == NULL ) {
			printf("tee: cannot open %s for writing.\n", argv[2]);
			exit(1);
		}
	}
	
	while ( fgets(str, MAXLINE, stdin) != NULL ) {
		printf("%s", str);
		fputs(str, fp);
	}
	exit(0);
}