Xref: utzoo comp.lang.c:19271 comp.unix.wizards:16828 Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!att!cbnewsl!mpl From: mpl@cbnewsl.ATT.COM (michael.p.lindner) Newsgroups: comp.lang.c,comp.unix.wizards Subject: Re: redirect stdin when using execl Summary: use system(3) Keywords: execl redirect stdin < Message-ID: <769@cbnewsl.ATT.COM> Date: 9 Jun 89 20:07:47 GMT References: <414@sc50.UUCP> Organization: AT&T Bell Laboratories Lines: 24 In article <414@sc50.UUCP>, ron@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