Reputation: 1277
Is there any way to run .bat file in Linux environment? I have a couple of .bat files, the purpose of them is to call mvn install:install-file scripts. Thus nothing OS dependent is in the scripts.
Thank you,
Upvotes: 11
Views: 89716
Reputation: 3450
Contrary to what others said, there is at least one interpreter for .bat
files on linux:
http://dcjtech.info/topic/winescript/
Upvotes: 0
Reputation: 3
You can run any batch file easily in linux with notepad++, you can find notepad++ in any linux app store. I had downloaded it from snap store which is for linux. Notepad++ have a option named run, it will run the batch file for you on any environment
Upvotes: 0
Reputation: 138
On Linux Terminal type
wine cmd
After that windows cmd will be played on your terminal. Go to the folder where your .bat file is located and type the bat files name and press enter. It will successfully run.
Upvotes: 4
Reputation: 2839
Install dosbox
sudo apt install dosbox
Run it with
dosbox
Mount your home folder from your Linux os. Type inside dosbox
MOUNT D /home/<your user>
Switch folder drive
D:
Now if you have a file called my.bat
in your user home directory, then inside doxbox just run it
MY.BAT
Upvotes: 0
Reputation: 56
You could write the equivalent of your .bat script as a shell script.
Upvotes: -2
Reputation: 31
The simple answer is yes there is a way to run it on Linux as long as:
.bat
file are in the $PATH
on your Linux boxYou will need to make the file executable and most likely prepend the contents of the file with a line that tells Linux which shell to run the script with. Something like this for bash: #!/bin/bash
Upvotes: 3
Reputation: 30167
You can use wine
or dosbox
, but in general there is no known bat
interpreter for linux. There are, however, implementations of various unix shells for windows, there's even a standard toolkit, Windows Services for UNIX
(a.k.a. SUA
), which include ksh
implementation and many other nice goodies, so if you want it OS-transparent, you could consider using that and write your scripts in a POSIX-compliant shell scripting language.
--- edit ---
On the other hand, if your script contains nothing else other than an mvn <params>
, you can just make sure the file has execute permissions (x
flag), prepend it with a shell interpreter (like /bin/bash script.bat
) and have a go at it. Success not guaranteed, though.
Upvotes: 17
Reputation: 10786
No. The bat
files are windows shell scripts, which probably execute windows commands and expect to run in a windows environment. You need to convert them to shell scripts in order to run them on linux, as your bash shell can not understand dos commands. Luckily, if the install file scripts are truly platform-independent, that should be easy. If you show an example, we may be able to help you translate.
Upvotes: -1