Article View: comp.sys.atari.st
Article #39470Re: shell help
From: Bob Waltenspiel
Date: Thu, 14 Dec 1989 21:08
Date: Thu, 14 Dec 1989 21:08
48 lines
1443 bytes
1443 bytes
> "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);
}
Technical Details
Message-ID:
<750041@hpsad.HP.COM>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!caesar.cs.montana.edu!ogicse!ucsd!ucsdhub!hp-sdd!hplabs!hpl-opus!hpnmdla!hpsad!bobwReferences:
<1867@calvin.cs.mcgill.ca>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!caesar.cs.montana.edu!ogicse!ucsd!ucsdhub!hp-sdd!hplabs!hpl-opus!hpnmdla!hpsad!bobw From: bobw@hpsad.HP.COM (Bob Waltenspiel) Newsgroups: comp.sys.atari.st Subject: Re: shell help Message-ID: <750041@hpsad.HP.COM> Date: 14 Dec 89 21:08:46 GMT References: <1867@calvin.cs.mcgill.ca> Organization: HP Signal Analysis Div - Rohnert Park, CA Lines: 48