OS X - Operating System General OS operation information and support

Opening .bat files


Post Reply New Thread Subscribe

 
Thread Tools
Beatles Fan

 
Member Since: Jul 05, 2010
Posts: 6
Beatles Fan is on a distinguished road

Beatles Fan is offline
How would I go about opening a .bat file meant for a Windows computer on a Mac? I know I would have to edit it/rewrite some of it, but what exactly do I edit?
QUOTE Thanks
Raz0rEdge

 
Raz0rEdge's Avatar
 
Member Since: Jul 17, 2009
Location: MA
Posts: 5,845
Raz0rEdge has much to be proud ofRaz0rEdge has much to be proud ofRaz0rEdge has much to be proud ofRaz0rEdge has much to be proud ofRaz0rEdge has much to be proud ofRaz0rEdge has much to be proud ofRaz0rEdge has much to be proud ofRaz0rEdge has much to be proud ofRaz0rEdge has much to be proud of
Mac Specs: 27" i7 iMac with 16GB RAM and 1TB HDD, iPhone 3G & 4, iPod Nano 16GB, iPod Shuffle, iPad 2 16GB WiFi

Raz0rEdge is offline
Without knowing what the .BAT file actually contains, it's hard for us to know what you have to change..

Regards
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Ottawa
Posts: 15,328
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
You're going to have to change 99% of it, if not everything. OS X and Windows use two very different approaches to CLI scripting. If you post what you have, perhaps I (we) can help you rewrite it.

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog :: M-F IRC Channel - Chats every Sunday at 8PM EST.
QUOTE Thanks
Beatles Fan

 
Member Since: Jul 05, 2010
Posts: 6
Beatles Fan is on a distinguished road

Beatles Fan is offline
My father has helped with .bat files before, and I don't think he changed all that much of them. Anyway, this is the text in it.


@echo off
COLOR 09
title SilabGarza Client v3.6
cd .\FILES\
java -Xmx1000m -cp .;Theme.jar Bot 0 0 lowmem members 32
pause

For the future, it would also be helpful to know how to rewrite them myself, without having to resort to posting on the forum

P.S. When my father helped rewrite them, I am 99% sure he used Terminal. I'm not sure how he did that though, so any help would be appreciated

Last edited by Beatles Fan; 07-05-2010 at 06:11 PM.
QUOTE Thanks
Beatles Fan

 
Member Since: Jul 05, 2010
Posts: 6
Beatles Fan is on a distinguished road

Beatles Fan is offline
Still need help
QUOTE Thanks
mrplow

 
mrplow's Avatar
 
Member Since: Oct 01, 2007
Location: UK
Posts: 5,397
mrplow has a brilliant futuremrplow has a brilliant futuremrplow has a brilliant futuremrplow has a brilliant futuremrplow has a brilliant futuremrplow has a brilliant futuremrplow has a brilliant futuremrplow has a brilliant futuremrplow has a brilliant futuremrplow has a brilliant futuremrplow has a brilliant future
Mac Specs: 27" iMac i7 (2011), iPhone5, iPad3, AppleTV2

mrplow is offline
BAT files are just text files. They contain script commands that Windows can interpret.

They can be edited on most platforms in any plain text editor (on OSX try TextEdit or Text Wrangler).

As to your question what to change . . . that's near impossible to answer. The file you've posted above appears to invoke a precompiled java app using a set of parameters.

I'd hazard a guess that it's a bespoke app of some kind.

You can change the commands by just typing/overtyping. But asking what to change is a nearly impossible question to answer from the info you've supplied I'm afraid.

You'd need to state what you are trying to do, what it does now and what it needs to do, but even then what you're asking is somewhat 'tricky'.

What's the end result you want to achieve? Are you trying to run this java app on Mac?

External hard disk acquisition addict - but admitting the problem is the first step to a robust backup

Please use the reputation system if you think you've been helped - top right of this post
QUOTE Thanks
Beatles Fan

 
Member Since: Jul 05, 2010
Posts: 6
Beatles Fan is on a distinguished road

Beatles Fan is offline
Quote:
Originally Posted by mrplow View Post
BAT files are just text files. They contain script commands that Windows can interpret.

They can be edited on most platforms in any plain text editor (on OSX try TextEdit or Text Wrangler).

As to your question what to change . . . that's near impossible to answer. The file you've posted above appears to invoke a precompiled java app using a set of parameters.

I'd hazard a guess that it's a bespoke app of some kind.

You can change the commands by just typing/overtyping. But asking what to change is a nearly impossible question to answer from the info you've supplied I'm afraid.

You'd need to state what you are trying to do, what it does now and what it needs to do, but even then what you're asking is somewhat 'tricky'.

What's the end result you want to achieve? Are you trying to run this java app on Mac?

Yes, I'm trying to run the Java file on my Mac. If you need any other information, I'm afraid I don't know enough about this to help. All I know is that I have to rewrite it to make it run
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Ottawa
Posts: 15,328
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
Try the following:
Code:
#!/bin/sh
cd <location> (replace with the location of the jar)
java -Xmx1000m -cp .;Theme.jar Bot 0 0 lowmem members 32
If you still need the pause at the end, take a look at this.

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog :: M-F IRC Channel - Chats every Sunday at 8PM EST.
QUOTE Thanks
Beatles Fan

 
Member Since: Jul 05, 2010
Posts: 6
Beatles Fan is on a distinguished road

Beatles Fan is offline
Quote:
Originally Posted by vansmith View Post
Try the following:
Code:
#!/bin/sh
cd <location> (replace with the location of the jar)
java -Xmx1000m -cp .;Theme.jar Bot 0 0 lowmem members 32
If you still need the pause at the end, take a look at this.
By the "location of the jar" do you mean something like /Users/Name/Desktop/SilGar\ v3.6/FILES? I tried doing that, then I opened the BAT file in Terminal, and then it said:

Code:
/Users/danny/Desktop/SilGar v3.6/Run.bat: line 3: Theme.jar: command not found
And then below that, it says what I told the pause prompt to say.
QUOTE Thanks
lifeisabeach

 
lifeisabeach's Avatar
 
Member Since: Sep 30, 2007
Location: Wilmington, NC
Posts: 5,787
lifeisabeach has a reputation beyond reputelifeisabeach has a reputation beyond reputelifeisabeach has a reputation beyond reputelifeisabeach has a reputation beyond reputelifeisabeach has a reputation beyond reputelifeisabeach has a reputation beyond reputelifeisabeach has a reputation beyond reputelifeisabeach has a reputation beyond reputelifeisabeach has a reputation beyond reputelifeisabeach has a reputation beyond reputelifeisabeach has a reputation beyond repute
Mac Specs: iMac i3 (mid-2010) + OS 10.8; TV 2; iPhone 4S; iPad 1

lifeisabeach is offline
Perhaps simply using the Jar Launcher app in OS X will suffice, and bypass the need for command line scripting.
How to Execute a .jar File In Os X - Mac Support


Standing request for all troubleshooting: Please provide your Mac model/year and OS version. Also advise us if you have used or installed any antivirus, security, or "cleaning" software on your Mac. If you have installed MacKeeper in particular, you are hereby advised to uninstall it.
---------
If all else fails to fix your problem, read this tip.
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Ottawa
Posts: 15,328
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
Quote:
Originally Posted by Beatles Fan View Post
By the "location of the jar" do you mean something like /Users/Name/Desktop/SilGar\ v3.6/FILES? I tried doing that, then I opened the BAT file in Terminal, and then it said:

Code:
/Users/danny/Desktop/SilGar v3.6/Run.bat: line 3: Theme.jar: command not found
And then below that, it says what I told the pause prompt to say.
Hold on, we're going to start over. First off, if Jar Launcher works for you, go with it. It may not work because it looks as if you're passing parameters to the jar file. Otherwise, let's start again.

First, open up an editor and paste in the following:
Code:
#!/bin/sh
java -Xmx1000m -cp .;<location>/Theme.jar Bot 0 0 lowmem members 32
Replace <location> with the location of the jar. So, using your example, if the jar file was in /Users/Name/Desktop/SilGar\ v3.6/FILES, make sure the contents of this file read as such:
Code:
#!/bin/sh
java -Xmx1000m -cp .;/Users/Name/Desktop/SilGar\ v3.6/FILES/Theme.jar Bot 0 0 lowmem members 32
Save that with the extension .sh. Make sure to save it as plain text (if you're using TextEdit, go to Format > Make Plain Text before saving). Now, open up a Terminal and type the following:
Code:
chmod +x <location of sh file>/<sh file>
For example:
Code:
chmod +x /Users/Name/jar_launcher.sh
Once that is done, your script is ready to execute. If you want to execute it, simply type the directory and name of the script at the Terminal prompt. For example:
Code:
/Users/Name/jar_launcher.sh

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog :: M-F IRC Channel - Chats every Sunday at 8PM EST.
QUOTE Thanks
Beatles Fan

 
Member Since: Jul 05, 2010
Posts: 6
Beatles Fan is on a distinguished road

Beatles Fan is offline
Quote:
Originally Posted by vansmith View Post
Hold on, we're going to start over. First off, if Jar Launcher works for you, go with it. It may not work because it looks as if you're passing parameters to the jar file. Otherwise, let's start again.

First, open up an editor and paste in the following:
Code:
#!/bin/sh
java -Xmx1000m -cp .;<location>/Theme.jar Bot 0 0 lowmem members 32
Replace <location> with the location of the jar. So, using your example, if the jar file was in /Users/Name/Desktop/SilGar\ v3.6/FILES, make sure the contents of this file read as such:
Code:
#!/bin/sh
java -Xmx1000m -cp .;/Users/Name/Desktop/SilGar\ v3.6/FILES/Theme.jar Bot 0 0 lowmem members 32
Save that with the extension .sh. Make sure to save it as plain text (if you're using TextEdit, go to Format > Make Plain Text before saving). Now, open up a Terminal and type the following:
Code:
chmod +x <location of sh file>/<sh file>
For example:
Code:
chmod +x /Users/Name/jar_launcher.sh
Once that is done, your script is ready to execute. If you want to execute it, simply type the directory and name of the script at the Terminal prompt. For example:
Code:
/Users/Name/jar_launcher.sh
What I tried did not work, so just to recap:

1. Edit the run.bat file to #!/bin/sh
java -Xmx1000m -cp .;<location> Bot 0 0 lowmem members 32, and save it with the extension .sh
2. Open terminal and enter chmod +x /Users/danny/Desktop/SilGar\ v3.6/Run.sh
3. Hit enter

Sorry for being so uneducated in terms of programming
QUOTE Thanks
scathe

 
scathe's Avatar
 
Member Since: Jan 12, 2009
Location: Prague, Czech Republic
Posts: 1,096
scathe is a jewel in the roughscathe is a jewel in the rough
Mac Specs: 2,4Ghz 15" unibody

scathe is offline
Nice post lol

it's two commands:
1. "java -Xmx1000m -cp ."
-cp that will do a search for a class in the current dir, but why not just pass in the single class?
-Xmx100M is a setting for the heap size, what exactly are you trying to run lol?

2. "Theme.jar Bot 0 0 lowmem members 32"
you can retype this as:
java -jar Theme.jar Bot 0 0 lowmem members 32

I would edit the file in the following way:
java -Xmx1000m -cp .
java -jar Theme.jar Bot 0 0 lowmem members 32

save it in the same location as the original .bat, add execute permissions as described above

and dude, when some1 used <> it meant you needed to substitute that for the correct path, not write <location> in your script
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Ottawa
Posts: 15,328
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
Reading this might be useful. As it notes, if you put a semi-colon between two commands, it will execute the second regardless of whether there was an error with the first. If you put two ampersands between the commands, it will execute the second only if the first was successful.

So, you could put those two java commands on one line if you wanted:
Code:
java -Xmx1000m -cp . ; java -jar Theme.jar Bot 0 0 lowmem members 32
or
Code:
java -Xmx1000m -cp . && java -jar Theme.jar Bot 0 0 lowmem members 32

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog :: M-F IRC Channel - Chats every Sunday at 8PM EST.
QUOTE Thanks

Post Reply New Thread Subscribe


« what's the best FREE antivirus program for mac? | Imac G5 keeps shutting down »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Pages not opening ms word files! Rector OS X - Apps and Games 9 01-19-2010 09:35 AM
Quicksilver: Opening selected files AnthonyJK OS X - Apps and Games 1 04-15-2007 04:23 PM

All times are GMT -4. The time now is 03:07 AM.

Powered by vBulletin
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?