Another possibility is that NT doesn't have "which" unless you've added it using something like Cygwin or the MKS Toolkit. So there isn't enough information here to figure it out. We'd need to know:

<bl>

  • What shell you're using (CMD or something sh-like)
  • What the COMSPEC and SHELL variables are
  • What "which" is and whether it exists </bl> Anyway, if you just want a good which command, you might try this all-Perl solution (save as which.bat):

    @rem = '--*-Perl-*-- @echo off if "%OS%" == "Windows_NT" goto WinNT perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9 goto endofperl :WinNT perl -x -S "%0" %* if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl if %errorlevel% == 9009 echo You do not have Perl in your PATH. if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul goto endofperl @rem '; #!perl #line 15 # uses PATH and PATHEXT under NT my @path = split(';', $ENV{PATH}); my @pathext = split(';', $ENV{PATHEXT}); @pathext = qw(.com .exe .bat .cmd) if !@pathext; unshift(@pathext, ''); unshift(@path, '.'); my $all = 0; ARG: foreach my $arg (@ARGV) { if ($arg eq '-a') { $all = 1; next ARG; } foreach my $path (@path) { foreach my $ext (@pathext) { if (-f "$path\\$arg$ext") { print "$path\\$arg$ext\n"; next ARG if !$all; } } } } __END__ :endofperl

    In reply to Re: Perl & NT by bikeNomad
    in thread Perl & NT by Anonymous Monk

    Title:
    Use:  <p> text here (a paragraph) </p>
    and:  <code> code here </code>
    to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.