Sublime Forum

Running Perl From A Batch File

#1

Hello, I have a build system set up to run a batch file. The batch file uses perl and powershell commands, which work fine in a regular command window (when I run the batch file from there). My problem is when I run the batch file from the build system my output says perl is an unrecognized command.

My build system looks like the following (The exact path names have been replaced because this is for work):
{
“name”: “Build”,
“shell”: true,
“cmd”: [“C:\script.bat”],
}

Technically the script is running a Visual Studio build. Note the Visual Studio build is successful and running the batch file from cmd is also successful. Anyone know what my issue could be (or another solution to running the file straight from Sublime)? This is the first time I’ve ever worked with build systems so any info would be appreciated. I have looked at the various documentation already.

Thanks

0 Likes

#2

Generally, when a command works from a terminal but not from Sublime with an error message about an unrecognized command, the reason is because your PATH is not set correctly. Without the location to the perl command being stored in the path, the batch file can’t find it to execute it.

Does the batch file work from a standard command prompt or only from a “Visual Studio” command prompt (on the windows machine I have handy it’s called “Developer Command Prompt for VS2013”)?

0 Likes

#3

It works from a standard command terminal. I have confirmed Perl is in PATH. I’ve also tried manually setting the PATH for this build system.

I am using Sublime Text 3 as well. That may be important.

0 Likes

#4

At first blush, that seems like it should work OK. The only other issue I can see with your original build is that you are using \ characters to separate the path, which are special in JSON strings, but I presume that’s not the case in the version with the original paths.

Since you’re using Sublime, you might want to try it like this instead, which may or may not make a difference (I don’t use Windows very often):

{
    "name": "Build",
    "shell_cmd": "C:/script.bat",
}

Something else to verify would be the setting of the COMSPEC environment variable; according to the documentation for the method that Sublime uses internally, that is what the Python runtime uses as the command interpreter.

0 Likes

#5

Apparently I was wrong, it does not work in terminal. I thought I saw it succeed but no such luck. I guess I’ll take a look at MSBuild. Thanks for the help.

0 Likes