www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/18/08:30:05

Sender: hecht AT DH_NRZ24 DOT dillinger DOT de
Message-ID: <3588FA4F.4487@dillinger.de>
Date: Thu, 18 Jun 1998 14:30:23 +0300
From: Michael Hecht <michael DOT hecht AT dillinger DOT de>
MIME-Version: 1.0
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
CC: djgpp AT delorie DOT com
Subject: Re: using redir
References: <Pine DOT SUN DOT 3 DOT 91 DOT 980618145728 DOT 24854B-100000 AT is>

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019