in reply to How do I run a .bat file?

In general, on a windows machine, you need to specify a binary executable. So you can't run .bat files directly.

Fortunately, command.com does know how to run .bat files. So if you change your call to:

system ("command.com /c d:\webmaster\cgi-bin\comb.bat");
you should be alright (subject to having to specify where command is (hopefully you don't need to).

Then again, the above answers might be the right ones: I don't use perl on windows

Replies are listed 'Best First'.
Re: Re: How do I run a .bat file?
by tye (Sage) on Oct 24, 2001 at 23:03 UTC

    Perl already does that for you and does a better job of it. (:

            - tye (but my friends call me "Tye")
      True, but this bat file is the only way we've can run this series of executables that expect input that we have. Even with all of the great information I've gotten here, I haven't been able to make it work. Perhaps I'll tell the engineer who wants me to write this that it can't be done with this particular file! ;-)

      Thanks again -
      ~E

        No, you misunderstood what I was saying. I was replying to this:

        In general, on a windows machine, you need to specify a binary executable. So you can't run .bat files directly.
        Which may be true in general of windows but isn't true of Perl's system(). Because:
        Fortunately, command.com does know how to run .bat files. So if you change your call to:
        system ("command.com /c d:\webmaster\cgi-bin\comb.bat");
        Well, that is the bit that "Perl already does that for you and does a better job of it". Perl already knows how to run command.com (or cmd.exe, depending on which version of Windows is involved) in order to execute programs that Win32's CreateProcess() call doesn't know how to run directly.

        Now, the bit of code quoted above made the same mistake you did. You need to double the backslashes in it.

        And I have no problem using system to run Windows batch files. If you have already tried doubling the backslashes and it still didn't work, then perhaps you should give us more details about how that failed and even include cut'n'pasted output from something like "dir d:\webmaster\cgi-bin\comb*" and what version of Perl you are using.

                - tye (but my friends call me "Tye")
        Perl can do pretty much anything batch files can do, and then some. What is this batch file doing, exactly?
Re: Re: How do I run a .bat file?
by data64 (Chaplain) on Oct 24, 2001 at 05:55 UTC
    I believe you need to use "cmd.exe" if it is Win NT or W2K. "command.com" is for the Win9X platforms.
Re: Re: How do I run a .bat file?
by Etelka (Novice) on Oct 24, 2001 at 05:05 UTC

    Thanks for the reply. So the system command can run more than one command?

    (I actually tried it, and it didn't so I'm beginning to think there is something wrong with the machine or the perl install. But, I figure that no matter what's wrong with the machine/install, I'm still going to have to figure out how to do it...)

    E

      Nope, it's running one command, with two parameters (/c and blah.bat). type

      command /?
      at the command prompt to see the details