[net.micro.atari16] Redirection & chaining

G.BRI%DEEP-THOUGHT@EDDIE.MIT.EDU (Brian Totty) (10/29/86)

	Could someone tell me if it is possible to redirect standard output
	to a file, and then chain to a program with its output dumped to the
	file.  What I want to do, is make a GEM shell for the Alcyon C compiler
	along with build capabilities, to have a nice GEM c development
	package.  I would like to have a way of grabbing any output from
	the program to check for errors, etc.

	Code samples to do the redirection would be great.  Is there any
	way that this will work?  Do programs return error codes to the calling
	program?  Thanks.

							--- Bri

					ARPA: g.bri@deep-thought.mit.edu
					UUCP: ...!eddie!bri

-------

bammi@cwruecmp.UUCP (Jwahar R. Bammi) (11/01/86)

In article <12250715809.8.G.BRI@DEEP-THOUGHT.MIT.EDU> G.BRI%DEEP-THOUGHT@EDDIE.MIT.EDU (Brian Totty) writes:
>
>	Could someone tell me if it is possible to redirect standard output
>	to a file, and then chain to a program with its output dumped to the
>	file.  What I want to do, is make a GEM shell for the Alcyon C compiler
>	along with build capabilities, to have a nice GEM c development
>	package.  I would like to have a way of grabbing any output from
>	the program to check for errors, etc.
>
>	Code samples to do the redirection would be great.  Is there any
>	way that this will work?  Do programs return error codes to the calling
>	program?  Thanks.
>
	The following code will redirect stdout to a file called 'foo'
		dup = Fdup(0);
		handle = Fopen("foo", 1); if handle < -5 ERROR;
		Fforce(0, handle);
		
	The following code executes another program and returns its exit
	status
		status = Pexec(0, "program.prg", tail, (char *)NULL);

	where :-
	program.prg : should be the complete pathname, including extention.
	tail :
		tail[0] = length of command tail;
		tail[1...len] = Command tail (args) '\0' terminated
	(char *)NULL for the environment means that the child process
		     inherits the environment of the parent. if you want
		     to pass an environment, it is of the form string of
		     strings, where each string if of the form "VAR=VALUE"

	The child process inherits all the open handles of the parent, so
	if you had redirected stdout in the parent, it will  be redirected
	in the child too.

	** BUG ALERT **
	Alcyon C (v4.14 and the earlier version) always returns success (0)
	status, even if there were compilation errors.
-- 
usenet: .....!decvax!cwruecmp!bammi		jwahar r. bammi
csnet:       bammi@case
arpa:        bammi%case@csnet-relay
compuServe:  71515,155

turner@imagen.UUCP (D'arc Angel) (11/02/86)

> 
> 	Could someone tell me if it is possible to redirect standard output
> 	to a file, and then chain to a program with its output dumped to the
> 	file.  What I want to do, is make a GEM shell for the Alcyon C compiler
> 	along with build capabilities, to have a nice GEM c development

you want to use the Fdup and Pexec calls, but may i recommend the
Beckemeyer Micro Cshell to you, its not very expensive and will
allow you to do pipes, redirect output etc., but wait there's
more...  it comes with a cc.prg that does exactly what you are
looking to do
-- 
----
		These are days for the locust to eat
					- Winston Churchill

Name:	James M. Turner
Mail:	Imagen Corp. 2650 San Tomas Expressway, P.O. Box 58101
        Santa Clara, CA 95052-8101
AT&T:	(408) 986-9400
UUCP:	...{decvax,ucbvax}!decwrl!imagen!turner
CompuServe: 76327,1575
GEnie     : D-ARCANGEL