Mail Archives: djgpp/1999/07/29/19:49:25
On Wed, 28 Jul 1999, Cesar S. Rabak wrote:
> >> About your system() command, you could do it as
> >>
> >> char show_files[] = "dir *.exe /s > exe_files.txt";
> >> system(show_files);
> >
> >Or, even better:
> >
> > FILE *fp = popen ("dir *.exe /s", "rt");
> > fread (fp, ...);
> >
> Eli, but in this case the popen would prefer to use the "dir.exe" in
> DJGPP/BIN, wouldn't?
Yes, it would; but so would `system'. They both do the same, so the
above two commands will work (or fail ;-) in the same way.
> If so, it will not honor the /s switch, but write in fp, something like "No
> /s: no such file or directory (ENOENT).
This is correct. I cannot imagine why would anyone want to launch a
child program just to list a directory anyway, but here you are, take 2:
FILE *fp = popen ("command.com /c dir *.exe /s", "rt");
fread (fp, ...);
An excercise that is left to the interested reader: why did I say
"command.com" and not simply "command"?
- Raw text -