in reply to Re: Windows: system() and PAUSE
in thread Windows: system() and PAUSE

Indeed, this worked (I just had to adjust the path, since I'm running Windows 2000):

>perl -we "system qw[ C:\WINNT\system32\cmd.EXE /c pause ];" Drücken Sie eine beliebige Taste . . . >perl -we "system qw[ cmd /c pause ];" Der Befehl "pause"" ist entweder falsch geschrieben oder konnte nicht gefunden werden.

This is really weird. It applies to all internal commands, while external ones work well even without specifying a path:
>perl -we "system qw[ cmd /c ls.exe ];" ....
I really would like to know what's going on here....
-- 
Ronald Fischer <ynnor@mm.st>

Replies are listed 'Best First'.
Re^3: Windows: system() and PAUSE
by ikegami (Patriarch) on Apr 09, 2010 at 18:37 UTC

    Which build of AS?

    Out of curiosity, which of the following work?

    perl -we"system qw[ cmd /c pause ];" perl -we"system qw[ cmd.exe /c pause ];" perl -we"system 'cmd /c pause';"
      Which build of AS?
      This is perl, v5.8.8 built for MSWin32-x86-multi-thread (with 18 registered patches, see perl -V for more detail) Copyright 1987-2007, Larry Wall Binary build 822 280952 provided by ActiveState http://www.ActiveState.com Built Jul 31 2007 19:34:48
      perl -we"system qw cmd /c pause ;"
      Does not work.
      perl -we"system qw cmd.exe /c pause ;"
      Works.

      AHA!!!!!

      But I checked my PATH, and there is only cmd.exe in the PATH, no cmd.bat, cmd.com, cmd.cmd .... And I changed my PATH so that it only contained the Perl bin directory, and C:\WINNT\system32, and the error still occurs.
      perl -we"system 'cmd /c pause';"
      Does not work.

      -- 
      Ronald Fischer <ynnor@mm.st>

        It's acting as if Perl removes any "cmd /c " prefixing the composed command. Maybe it's an attempt to fix the bug where the shell is called when it shouldn't on Windows. Deviations (such as adding .exe) fool the code in question.

        I can't replicate the problem with builds 817 and 824. AS doesn't offer old builds anymore, so I can't try 822.

        first it look for cmd.com, then cmd.exe, then cmd.bat, then cmd.cmd ..... PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
Re^3: Windows: system() and PAUSE
by cdarke (Prior) on Apr 09, 2010 at 10:27 UTC
    Maybe you have another version of cmd.exe in your path? Try using %comspec% - that works for me on Windows XP and 7.
    C:\>perl -we "system('%comspec% /c pause')" Press any key to continue . . .
      Maybe you have another version of cmd.exe in your path?
      No, only one. Checked with WO.EXE.

      -- 
      Ronald Fischer <ynnor@mm.st>
Re^3: Windows: system() and PAUSE
by BrowserUk (Patriarch) on Apr 09, 2010 at 10:31 UTC

    Does c:\WINNT\system32 appear in your path?

      Does c:\WINNT\system32 appear in your path?
      Yes, otherwise system('cmd /c ls.exe') and system('pause') wouldn't work either; plus, I would get an error message saying that CMD is not found.

      -- 
      Ronald Fischer <ynnor@mm.st>

        Do you have an environment varible PERL5SHELL defined?