redirect stdin when using execl

michael.p.lindner mpl at cbnewsl.ATT.COM
Sat Jun 10 06:07:47 AEST 1989


In article <414 at sc50.UUCP>, ron at sc50.UUCP ( Ron Winnacott ) writes:
> Hello net.
> execl("/bin/mail","mail","ron","<","/tmp/tfile",NULL);
> Ron Winacott.  Unisys Canada, Support center.

The problem is that the "<" meaning redirection is a feature of the shell,
not the operating system execl() call.  You can call system, described in
section 3 of your programmer's guide, instead, such as:

	char	buffer[32];	/* make sure it's big enough */
	char	*ron = "ron";	/* or whoever */
	char	*tempfile = "/tmp/tfile"; /* or whatever */

	sprintf(buffer, "/bin/mail %s < %s", ron, tempfile);
	if (system(buffer) == 0)
		/* yay! I sent mail! */ ;
	else
		/* boo!  It failed! */ ;

Mike Lindner
attunix!mpl
AT&T
190 River Rd.
Summit, NJ 17901



More information about the Comp.lang.c mailing list