0

I'm running Mac OS X El Capitan and I'm not quite sure how to launch a .bat extension anymore. I used to be able to just do it right away, but now it asks me to select an application to use to open it up. I don't know which to use. Please help.

edit: it used to work just fine and open in command center even though it has a .bat extension. It changed when I switched to El Capitan

edit 2:

java -Xmx3G -Xms2G -jar Tekkit.jar noggin
pause
11
  • perhaps there is some converter, but you should add a bit about where you got this .bat file and what is in it
    – barlop
    May 15, 2016 at 22:37
  • It's just a launcher for a minecraft tekkit server I used to play all time. I created it with textedit and it used to work
    – Greg
    May 15, 2016 at 22:40
  • i'm not familiar with mindcraft.. But are you aware that Macs since they run OSX would not execute windows batch files, they have their own BSD based shell, which has languages like bash or ksh, not batch. And the batch file aside, the minecraft server executable that runs on windows won't run on mac, you'd need a minecraft server executable that was compiled for mac (or something on the mac that can simulate a windows machine, and run the minecraft server)
    – barlop
    May 15, 2016 at 22:42
  • That's the thing though, it used to work just fine and open in command center even though it has a .bat extension. It changed when I switched to El Capitan
    – Greg
    May 15, 2016 at 22:44
  • you should add that point you just made into your question
    – barlop
    May 15, 2016 at 22:45

3 Answers 3

1

[updated: 2016-05-18] Missing the -jar parameter. Tks for pointing that out @barlop.

[updated: 2016-05-17] Disambiguation edits/improvements.

Please note: you do not need to download WINE [edit]just[/edit] to run a batch script. In fact, do not [edit]try to run batch, instead convert it to the equivalent shell script for your system[/edit].

As pointed out, .bat is script run by Microsoft's CLI. For Mac, I believe you need something along these lines ([edit]I've dug around and found Minecraft is Java and so[/edit]):

!# /bin/sh
java -jar ~/Library/Application Support/minecraft/bin/minecraft.jar

# Please note the above path is based on internet sources. Also, I'm
# not very Java knowledgeable but maybe someone can add/edit where needed.

Save it as a .sh file (and if needed chmod it to ug+x). Then place it wherever you wanted the shortcut to go (or in something akin to /usr/bin/ if you want it available system-wide).

Obviously, as others have said, without seeing the contents of the batch file, nobody here can give you a precise sh translation.

10
  • -1 Your first sentence is very very misleading. It almost suggest that there is another way he can run a batch script besides WINE, (maybe there is, maybe there isn't). That is exceptionally misleading, also considering that he claimed that he was able to run it in his previous version. What you are meaning to tell him is that he shouldn't try to run the batch script. You should tell him that you think he shouldn't try to run the batch script. And you are not telling him much at all, you're just telling him how to start a program in a *nix based OS.
    – barlop
    May 16, 2016 at 12:25
  • also You're not really adding anything that hasn't been mentioned in comment.
    – barlop
    May 16, 2016 at 12:29
  • @barlop: Yes, I worded it a little imperfectly and now I've edited it to reflect as much. However, on the subject of poor wording, and not to be rude, you just blatantly contradicted yourself in you first comment by calling your interpretation of my answer "misleading". You say "It almost suggest that there is another way he can run a batch script besides WINE, (maybe there is, maybe there isn't)" -- a contradiction. Notwithstanding the fact that OP claimed he could previously run it so clearly there was an interpreter present on his old setup.
    – nonzyro
    May 17, 2016 at 8:59
  • As to your comment about my not adding anything that wasn't mentioned before, I'd contend that I added a shell script template which, at the time of writing, it was more than anyone else had given so far. My answer, IMVHO was a much better suggestion than downloading WINE,
    – nonzyro
    May 17, 2016 at 9:04
  • You added what you call a "shell script template", which is just how to run a*nix program in *nix',, A)that is really a separate question to how to launch a bat in *nix, and B)how to run a *nix program in *nix is so basic and so easily googlable I wouldn't even count it as an addition. And generally, a don't do that do this answer isn't really a proper answer it's more of a comment, and when the content is something so basic and easily googlable, it's very low value. At least to download WINE directly answers the question.
    – barlop
    May 17, 2016 at 13:53
0

.bat files are native to Windows, not Mac OS.

In order to launch a .bat file, you will need to use something on the mac that launches windows executables, such as wine, etc.

Alternatively, find a mac version of the program you're launching. Its likely have its own kind of scripting in the form of a bash or ksh file. Batch (.bat, .cmd) files are scripts too, but written for windows.)

4
  • and i'd add to the last sentence that a normal thing would be to use a script for a *nix based OS, e.g. bash/ksh,
    – barlop
    May 15, 2016 at 22:44
  • So which extension should I use?
    – Greg
    May 15, 2016 at 22:47
  • @Greg you could add more info to your question for example, show the contents of the bat file that you say used to work, as well as where you got it from.
    – barlop
    May 16, 2016 at 2:10
  • @barlop added. tnx.
    – LPChip
    May 16, 2016 at 11:44
0

Here is some basic Unix info. Not many "El Capitan"-specific details are provided, but they should not be needed to get things to work. (I understand that an upgrade to "El Capitan" broke things. Perhaps it changed what is in your path, or altered some permissions. Following are details on how to make things work.

In DOS, a batch file is a text file that ends with ".BAT" (case-insensitive, so ".bat" would also work). Microsoft Windows follows the DOS tradition. Each line in the batch file is a command to be run from the command interpreter.

In Unix, including Mac OS X, a proper "shell script" file should have a proper header, and have proper permissions. Then, after the header, each line in the batch file is a command to be run from the command interpreter.

Notice that those descriptions are mostly the same. Mainly, most of the script file is just a list of commands to run. Commands which are the same between DOS and Unix, like "cd ..", or the names of executable files within the PATH, may work equally well with both types of files.

If you had a Unix script file that said:
#!/bin/sh @Echo Off echo hello cd . more < readme.txt

Then the first line of the file would cause a harmless error in DOS/Windows, the second line of the file would cause a harmelss error message in Unix, and the rest of the file could work identically in both environments.

Whether this will actually work well for you, or not, may largely depend on what commands you use. For instance, "cd bin" can work well with both environments, but DOS/Windows use a backslash as a directory separator while Unix uses a forward slash. So some commands may not work well.

The best way for us to predict how well your particular batch file would work well, or not, is if we knew the contents of the batch file. Hence why barlop's comment asked about the contents of the batch file.

Regarding your question (from one of your comments) on which extension to use: In DOS/Windows, the answer is ".BAT" (any amount of lowercase is fine, so ".bat" is okay too.) In Unix, the most common standards are "none" (no extension), or ".sh". However, in Unix, the extension really doesn't matter significantly. What matters is whether the file has the necessary permissions, and possibly whether it starts with the appropriate header. So make sure those things are right. (The header is the first line shown in my prior sample. The permissions can be set using "chmod a+x filename.bat" but, of course, specify the actual location of the filename.) When you run the file in Unix, make sure to specify the entire filename of the script file, including the ".bat" extension. (If you don't like doing that, simply make a symlink, having a symlink named "gonow" point to "gonow.bat" (or whatever is approrpriate).

The other way to do this in Unix is to run the .BAT file from within another piece of software which is DOS-like. e.g., COMMAND.COM within Wine, or perhaps CMD.EXE within WINE, or other Wine variants like Crossover, or other software like DOSBox or DOSemu. If you do so use this software that is designed to work quite like DOS, then that software may be able to run the file without requiring that you specify the ".bat" extension.

Another alternative may be to simply use a Shell Script file that runs Java (since the contents of the batch file, mentioned elsewhere, show Java being run), and ignore trying to use a file that ends with the ".bat" extension. (So it wouldn't be a .bat file, but would be a shell script or a symbolic link.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .