How to launch a .bat

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

Greg

Posted 2016-05-15T22:36:54.370

Reputation: 9

perhaps there is some converter, but you should add a bit about where you got this .bat file and what is in it – barlop – 2016-05-15T22:37:46.143

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 – 2016-05-15T22:40:34.653

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 – 2016-05-15T22:42:49.377

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 – 2016-05-15T22:44:30.707

you should add that point you just made into your question – barlop – 2016-05-15T22:45:16.970

So what should I do? – Greg – 2016-05-15T23:57:23.787

Fantastic that you included the contents. Linux doesn't look at extensions. and in terms of file type, that might work as a *nix shell script too. You should include the error message when you tried to run that. (and then google the error message, and see what google says of that error message). e.g. it might be a permissions issue(chmod required), or it might be java needs to be installed. Or it might be your jar file doesn't exist at that location – barlop – 2016-05-17T13:58:23.043

I think quite possibly your .bat file wasn't running as a bat file but the contents would work as either a batch file or a *nix shell script. what happens if you do chmod 777 blah.bat and then run the command? (assuming you have java installed and the jar file there).. it might work – barlop – 2016-05-18T04:29:31.647

Thanks @barlop for pointing out that I was missing the -jar option (answer edited). OP, try running the first line "java -Xmx3G -Xms2G -jar Tekkit.jar noggin" without the pause and change Tekkit.jar to the full path, eg: ~/my-java-stuff/Tekkit.jar or try running the path to the minecraft file (apparently, according to the web, it's this): "~/Library/Application Support/minecraft/bin/minecraft.jar" – nonzyro – 2016-05-18T10:48:17.317

@nonzyro superuser/stackoverflow/ stackexchange sites can be really stupid with formatting.. he had put pause on a new line. Nevertheless, indeed, the pause line shouldn't be there. since running it as a bash script is what he was probably doing anyway. Worth noting that the pause wouldn't be the error he describes though. Though he doesn't describe the error much. He really needs to give the error message. – barlop – 2016-05-18T10:59:43.153

-1 Give the error message when you try to run your 'script'. (And when you try to run the one line command from a terminal). You haven't even stated the error. Stating that something doesn't work is completely insufficient. – barlop – 2016-05-18T11:02:08.543

Answers

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.

nonzyro

Posted 2016-05-15T22:36:54.370

Reputation: 113

-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 – 2016-05-16T12:25:43.367

also You're not really adding anything that hasn't been mentioned in comment. – barlop – 2016-05-16T12:29:03.227

@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 – 2016-05-17T08:59:26.663

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 – 2016-05-17T09:04:14.360

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 – 2016-05-17T13:53:21.807

If he had a batch file(which was the reasonable assumption that answerers made), then one may note with that (downloading WINE), as a little side note that one recommends just writing the one line shell script instead. then it'd be answering the question – barlop – 2016-05-17T14:01:33.890

U write " calling your interpretation of my answer "misleading"" <-- I did not say that.A)I referred to that first sentence being misleading - be specific B)II didn't say my interpretation was misleading, I said ur first sentence was misleading - I could see it had 2 interpretations, one was what you meant and one was very much not what you meant. u offer no solution to alternative to WINE to run a batch file. So don't claim that he doesn't need to run WINE to run a batch file.After he who wants to run a batch file reads your answer he STILL needs to run WINE if he wants to run a batch file – barlop – 2016-05-17T14:07:18.327

And I didn't contradict myself, i'm still open to your claim that he doesn't need WINE to run a batch file, though i'm waiting and I doubt you'll post any alternative TO RUN A BATCH FILE, 'cos I doubt you know of any, (though there may be), and I think you didn't mean to write that. Though you still haven't corrected / fulfilled your claim. As far as you are concerned, he MAY WELL NEED to run WINE to run a batch file, you just think he shouldn't run a bat file. So it looks like you said the opposite of what you meant even in your first sentence. – barlop – 2016-05-17T14:09:28.707

I'm going to presume English is not your native speak so my position on your contradiction stands: You said my sentence was misleading as it suggested one did not require WINE, but in the same breath, you said maybe it did not (and OP said he previously could run batch with no mention of WINE). I also stand by my solution being a better alternative to WINE. As for your claim to me not answering the actual question, I totally concede that I did not answer it but provided a pragmatic workaround instead. On that note, could we please just call it even now and walk away in a dignified manner. – nonzyro – 2016-05-17T21:22:27.763

Let us continue this discussion in chat.

– barlop – 2016-05-17T22:07:07.223

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.)

LPChip

Posted 2016-05-15T22:36:54.370

Reputation: 42 190

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 – 2016-05-15T22:44:47.237

So which extension should I use? – Greg – 2016-05-15T22:47:39.720

@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 – 2016-05-16T02:10:34.943

@barlop added. tnx. – LPChip – 2016-05-16T11:44:06.813

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.)

TOOGAM

Posted 2016-05-15T22:36:54.370

Reputation: 12 651