Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent of .bat in mac os

I currently use a .bat file that is utilized to invoke a java file. If I wanted to utilize the same functionality on Mac OS what format changes would I make? (unless the .bat equivalent on Mac OS is the .sh format?)

java -cp  ".;.\supportlibraries\Framework_Core.jar;.\supportlibraries\Framework_DataTable.jar;.\supportlibraries\Framework_Reporting.jar;.\supportlibraries\Framework_Utilities.jar;.\supportlibraries\poi-3.8-20120326.jar;D:\downloads\Selenium 2.0\selenium-server-standalone-2.19.0.jar" allocator.testTrack 

Any assistance would be appreciated.

like image 999
Ganeshja Avatar asked Dec 28 '12 05:12

Ganeshja


People also ask

Can we run BAT file in Mac?

bat files as they are only for a Windows PC, of no use on a Mac to other Unix computer.

What is alternative for BAT file?

The best alternative is PuTTY, which is both free and Open Source. Other great apps like Make Batch Files are cmder, PowerShell, KiTTY and Windows Command Prompt.


2 Answers

May be you can find answer here? Equivalent of double-clickable .sh and .bat on Mac?

Usually you can create bash script for Mac OS, where you put similar commands as in batch file. For your case create bash file and put same command, but change back-slashes with regular ones.

Your file will look something like:

#! /bin/bash java -cp  ".;./supportlibraries/Framework_Core.jar;./supportlibraries/Framework_DataTable.jar;./supportlibraries/Framework_Reporting.jar;./supportlibraries/Framework_Utilities.jar;./supportlibraries/poi-3.8-20120326.jar;PATH_TO_YOUR_SELENIUM_SERVER_FOLDER/selenium-server-standalone-2.19.0.jar" allocator.testTrack 

Change folders in path above to relevant one.

Then make this script executable: open terminal and navigate to folder with your script. Then change read-write-execute rights for this file running command:

chmod 755 scriptname.sh 

Then you can run it like any other regular script: ./scriptname.sh

or you can run it passing file to bash:

bash scriptname.sh 
like image 84
imslavko Avatar answered Sep 29 '22 15:09

imslavko


The common convention would be to put it in a .sh file that looks like this -

#!/bin/bash java -cp  ".;./supportlibraries/Framework_Core.jar;... etc 

Note that '\' become '/'.

You could execute as

sh myfile.sh 

or set the x bit on the file

chmod +x myfile.sh 

and then just call

myfile.sh 
like image 29
Brett Freer Avatar answered Sep 29 '22 16:09

Brett Freer