- Как запустить bat файл на linux
- Как в Wine запустить файл .bat и .msi
- Как в Wine запустить файл .msi
- How do I create a batch file and run it? [duplicate]
- 3 Answers 3
- Запустите .bat в среде Linux
- 7 ответы
- Do batch files work on linux?
- What is batch file in Linux?
- Can you run BAT files on Ubuntu?
- Does cmd work in Linux?
- What files run on Linux?
- How to run .bat(Batch) Files on Linux (Ubuntu)
- Why is permission denied Linux?
- Can you run EXE files on Linux?
- Is Windows a Linux terminal?
- Is Windows Terminal like Linux?
- Is CMD a terminal?
- What are .sh files in Linux?
- What is the Linux equivalent of a batch file?
- How do I run a .sh file in Linux?
- Can I run Windows .bat files in Ubuntu?
- 2 Answers 2
Как запустить bat файл на linux
I have a pretty basic problem here, that has happened so haphazardly to me that up until now, I’ve just ignored it. I downloaded tomcat web server and «Murach’s Java Servlets and JSP» book is telling me to navigate to the tomcat/bin directory and start the server my typing in Terminal
The relevant files in this directory are startup.sh and startup.bat. Typing both of these returns the same error message
So my questions are, what are .bat and sh files, and how do I run these files? I’ve read several tutorials for different languages and software programs, and some times when the tutorial says execute a bunch of files in the command line, I get a «command not found» error. Sometimes it works, sometimes it doesn’t. This is perplexing to me, so what are some common solutions to solving these sort of «command not found» Terminal problems?
Как в Wine запустить файл .bat и .msi
Вы можете запустить файл .bat разными способами:
Найдите файл .bat и запустите его двойным кликом.
И найдите в окне Проводника нужный вам файл.
чтобы сразу попасть в нужную папку.
Когда найдёте файл .bat, то дважды кликните на него.
Например, я хочу запустить файл «С ключом ADM.bat» из папки /mnt/disk_d/Share/Conses/ConsFed/, тогда я открываю эту папку командой
И в открывшемся окне двойным кликом запускаю файл «С ключом ADM.bat».
3. Вы можете запустить файл .bat в командной строке, используя конструкцию вида:
Если вы используете путь до файла в Linux, то обязательно нужно указать опцию /unix. Например, я хочу таким образом запустить файл «With-ADM.bat» который находится в папке /mnt/disk_d/Share/Conses/ConsFed/, тогда команда следующая:
Как в Wine запустить файл .msi
Файлы MSI нельзя запускать напрямую; вам нужно использовать либо программу Wine msiexec, либо запуск Wine с терминала:
How do I create a batch file and run it? [duplicate]
should I use the text editor? the extension should be .sh or .bat?
3 Answers 3
To create one use the .sh extension but it doesn’t really matter but it helps future users to quickly determine which file type it is. The bat name is mostly used on Windows but in Linux file name extensions do not really matter. Meaning I can call my file say run.de and it would still run in bash file but I believe it’s a good practice to name them with the .sh file extension.
For the editor, part uses any that is best for you between nano vim gedit emacs , but I believe gedit would be nice to start with.
Запустите .bat в среде Linux
Есть ли способ запустить файл .bat в среде Linux? У меня есть пара файлов .bat, их цель — вызывать сценарии mvn install:install-file. Таким образом, в сценариях нет ничего зависящего от ОС.
7 ответы
Вы можете использовать wine or dosbox , а вообще неизвестно bat интерпретатор для линукса. Есть, правда, реализации различных unix-оболочек для windows, есть даже стандартный набор инструментов, Windows Services for UNIX (также известный как SUA ), который включает в себя ksh реализация и многие другие приятные преимущества, поэтому, если вы хотите, чтобы он был прозрачным для ОС, вы можете рассмотреть возможность его использования и написать свои сценарии на языке сценариев оболочки, совместимом с POSIX.
— редактировать — С другой стороны, если ваш скрипт содержит ничего больше кроме mvn , вы можете просто убедиться, что у файла есть права на выполнение ( x флаг), добавьте к нему интерпретатор оболочки (например, /bin/bash script.bat ) и попробуй. Однако успех не гарантирован.
Спасибо за ответ. Скрипт использует команды set, rem, call. Они не распознаются в среде Unix. Очень жаль, что такой интерпретатор еще не создан. — Скизер
Большая загвоздка здесь в том, что пакетные файлы Windows, вероятно, используют CRLF в качестве разделителей строк, которые bash имеет причудливую тенденцию подавлять. Использовать dos2unix для преобразования из CRLF в формат CR. — Цифровая травма
Простой ответ: да, есть способ запустить его в Linux, если:
- Команды, которые вы запускаете из .bat файл находится в $PATH на вашем Linux-боксе
- Вы не используете специфичные для Microsoft команды файлов BATCH или управляющие структуры.
Вам нужно будет сделать файл исполняемым и, скорее всего, добавить к содержимому файла строку, которая сообщает Linux, в какой оболочке запускать скрипт. Что-то вроде этого для bash: #!/bin/bash
Do batch files work on linux?
Unfortunately, many of the answers such people receive state that batch scripts cannot run on Linux. However, Linux users can indeed run batch files. Also, Windows batch files can be run on Windows like a native shell script.
What is batch file in Linux?
A batch file is a script file in DOS, OS/2 and Microsoft Windows. It consists of a series of commands to be executed by the command-line interpreter, stored in a plain text file. . Unix-like operating systems, such as Linux, have a similar, but more flexible, type of file called a shell script.
Can you run BAT files on Ubuntu?
bat file, it will open in gedit>Tools>External Tools>Run command>in the popped up box type ‘wineconsole cmd‘ (without inverted commas)>OK. 5. A Wine console terminal will pop up, in it type ‘start yourfilename. bat’ and hit enter.
Does cmd work in Linux?
Most of us think that Linux has terminal and we can use a command-line interface only in Linux but it is just a myth. There is a PowerShell and a command prompt in windows as well where we may execute the commands easily. But Windows and Linux have commands with the same name as well.
What files run on Linux?
A RUN file is an executable file typically used to install Linux programs. It contains program data and installation instructions. RUN files are often used to distribute device drivers and software among Linux users. You can execute RUN files in the Ubuntu terminal.
How to run .bat(Batch) Files on Linux (Ubuntu)
45 related questions found
Why is permission denied Linux?
While using Linux, you may encounter the error, “permission denied”. This error occurs when the user does not have the privileges to make edits to a file. . Other users, however, may not be allowed to make such edits. Remember that only root or users with Sudo privileges can change permissions for files and folders.
Can you run EXE files on Linux?
1 Answer. This is totally normal. .exe files are Windows executables, and are not meant to be executed natively by any Linux system. However, there’s a program called Wine which allows you to run .exe files by translating Windows API calls to calls your Linux kernel can understand.
Is Windows a Linux terminal?
Windows Terminal is a modern terminal application for users of command-line tools and shells like Command Prompt, PowerShell, and Windows Subsystem for Linux (WSL).
Is Windows Terminal like Linux?
The Windows Terminal is a modern, fast, efficient, powerful and productive terminal application. It combines many command-line tools and shells such as Command Prompt, PowerShell and WSL (Windows Subsystem for Linux).
Is CMD a terminal?
So, cmd.exe is not a terminal emulator because it is a Windows application running on a Windows machine. There is no need to emulate anything. It is a shell, depending on your definition of what a shell is.
What are .sh files in Linux?
An SH file is a script programmed for bash, a type of Unix shell (Bourne-Again SHell). It contains instructions written in the Bash language and can be executed by typing text commands within the shell’s command-line interface.
What is the Linux equivalent of a batch file?
Batch file equivalent in linux is shell script (. sh). You can use gedit, vim or any other text editor available to create one.
How do I run a .sh file in Linux?
- Select the file using mouse.
- Right-click on the file.
- Choose Properties:
- Click Permissions tab.
- Select Allow executing file as a program:
- Now click the file name and you will be prompted. Select “Run in the terminal” and it will get executed in the terminal.
Can I run Windows .bat files in Ubuntu?
I want to run a .bat file in ubuntu, but it just opens the text editor. Here’s the code of the .bat file(you can play it):
@echo off set /a guessnum=0 set /a answer=%RANDOM% echo Welcome to the Guessing Game! echo. echo Try and Guess my Number! echo. echo. goto guess :guess set /p guess= set /a guessnum=%guessnum% +1 if %guess% GTR %answer% ECHO Lower! if %guess% LSS %answer% ECHO Higher! if %guess% EQU %answer% GOTO EQUAL goto goto guess :equal echo Congratulations, You guessed right. echo. echo It took you %guessnum% guesses. echo. pause
The file is seen as being text; hence opening in the text editor. Files are marked as executable via chmod (or GUI tools) which you didn’t do, but the file must have an interpreter installed that knows how to execute it (usually the type of file can be determined, but the shebang on first line is always a safety item to ensure it’s interpreted correctly — your file has none). You’ll need to add software that knows how to interpret it, as it’s not BASH script, not perl, not python, not CSH etc.
This code is erroneous, so there is no output from this batch file. The statement goto top can’t be executed because there is no label named :top in this batch file. Debugging batch files is off topic at Ask Ubuntu. Try asking for help at a Windows site or Stack Overflow.
2 Answers 2
By the looks of it, most of it (the parts using the “echo” command) should work, but not the batch-specific parts (e.g. “goto”). But you should be able to convert it to a shell script and then it might work, or you may be able to emulate it within Ubuntu.
Edit: I’ve converted it, it appears to be incomplete. It appears to have converted the «if» parts, but not anything else. Let me know if it works (I highly doubt it), I’ll also try it personally. I hope it helps. (Moderators, please update this answer with a fully converted script if possible.)
export -a guessnum=0 export -a answer=$ echo Welcome to the Guessing Game! echo "" echo Try and Guess my Number! echo "" echo "" export -p guess= export -a guessnum=$ +1 if $ echo Lower! if $ echo Higher! if $ echo EQUAL goto top :equal echo Congratulations, You guessed right. echo "" echo It took you $ guesses. echo "" pause