develooper Front page | perl.perl5.porters | Postings from May 2004

Re: Problem with system() on Win9x and command.com (perl 5.8.x-5.9.x)

Thread Previous | Thread Next
From:
Steve Hay
Date:
May 6, 2004 05:05
Subject:
Re: Problem with system() on Win9x and command.com (perl 5.8.x-5.9.x)
Message ID:
409A2AB0.8080702@uk.radan.com
bilbo@ua.fm wrote:

>>>Because of this, system('test_bat.bat 1 2 3 4 5 6 7 8 9') really run
>>>'"test_bat.bat 1 2 3 4 5 6 7 8 9"', and command.com can't understand this.
>>>
>>>I make patch for this bug.
>>>
>>>--- win32/win32.c       Wed Feb 04 04:22:18 2004
>>>+++ win32/win32.c       Sat Apr 17 15:02:42 2004
>>>@@ -3538,11 +3538,12 @@
>>>        if (clen > 4
>>>            && (stricmp(&cname[clen-4], ".bat") == 0
>>>                || (IsWinNT() && stricmp(&cname[clen-4], ".cmd") == 0)))
>>>        {
>>>            bat_file = TRUE;
>>>-           len += 3;
>>>+           if (!IsWin95())
>>>+               len += 3;
>>>      
>>>
>
>RGS> Sorry for haven't answering to this earlier, but I'm a bit uncomfortable
>RGS> to rely on the operating system version to determine which command shell
>RGS> is used. Couldn't you instead look at the shell name? (I haven't any
>RGS> Win32 machine to test.)
>
>It can be right you. But I have chosen, as I think, the most simple
>variant of the fix, because perl/w32 use very strange strategy for
>external application run:
>
>Another arguments. WinNT never use command.com.
>
I've never actually used command.com on WinNT, but it does exist - 
probably for compatibility with Win9x software.

However, it may well be that your original patch (switching on the OS 
rather than the shell) is correct, because the command.com on my WinXP 
system doesn't seem to behave like the command.com on your Win9x 
system:  If I switch to command.com and run your "test.pl" program 
(using perl 5.8.4) then I get:

1 - 1
2 - 2
3 - 3
4 - 4
5 - 5
6 - 6
7 - 7
8 - 8
9 - 9
1 - 1
2 - 2
3 - 3
4 - 4
5 - 5
6 - 6
7 - 7
8 - 8
9 - 9

exactly as I do using cmd.exe.  The same is true on Win2K and WinNT.  
The copyright notice on the WinXP command.com says 1990-2001, while on 
Win2K it says 1990-1999 and on WinNT it says 1990-1996.

I dare say the Win9x systems (Win95/98/ME) each have different 
command.com's too.  I don't know if your test program fails on all three 
of those systems (I don't have any to test on), but it does look like 
switching on the OS is likely to be better than switching on the shell.

- Steve



------------------------------------------------
Radan Computational Ltd.

The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only.  If you have received this message in error or there are any problems, please notify the sender immediately.  The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden.  Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd.  The recipient(s) of this message should check it and any attached files for viruses: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email.


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About