X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: NoEmailAds AT execpc DOT com (Chris Giese) Newsgroups: comp.os.msdos.djgpp Subject: Re: How do I feed output of DOS commands into a program? Date: Thu, 29 Jan 2004 02:58:18 GMT Organization: PROPULSION GROUP Message-ID: <401875b6.1196777@news.voyager.net> References: <4017ddaa$1_6 AT Newsfeeds DOT com> X-Newsreader: Forte Free Agent 1.21/32.243 X-Complaints-To: abuse AT supernews DOT com Lines: 18 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Nathan Kreiger" wrote: >Greetings, group. I'm writing a program in C++ and compiling with >DJGPP's gxx, and I'd like to be able to run DOS commands such >as "CD" (get current directory) and funnel the result back into my >program, without using temporary files. I could always do: Use popen() and pclose(): #include int main(void) { static char buf[8000]; FILE *pipe = popen("CD", "r"); (void)fread(buf, 1, sizeof(buf), pipe); pclose(pipe); printf("%s", buf); return 0; }