Mail Archives: djgpp/1998/06/18/08:30:05
Eli Zaretskii wrote:
>
> On Thu, 18 Jun 1998, Michael Hecht wrote:
>
> > Next question : Is there any command available like 'which' in UNIX ?
>
> You can easily write it yourself, using the library function
> __dosexec_find_on_path. For example (untested!):
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <libc/dosexec.h>
>
> int main (int argc, char *argv[])
> {
> char full_path[FILENAME_MAX];
> extern char **environ;
>
> if (argc <= 1)
> {
> printf ("Usage: %s progname\n", argv[0]);
> return 0;
> }
>
> if (__dosexec_find_on_path (argv[1], (char **)0, full_path) == NULL &&
> __dosexec_find_on_path (argv[1], environ, full_path) == NULL)
> printf ("%s: Command not found\n", argv[1]);
> else
> printf ("%s\n", full_path);
>
> return 0;
> }
Thank You, it works !!!
- Raw text -