What is different between *.bat and *.sh and *.exe file? - batch-file

When I start Apache Tomcat
start
tomcat/bin/startup.bat
tomcat/bin/startup.sh
stop
tomcat/bin/shutdown.bat
tomcat/bin/shutdown.sh
1. What is different between *.sh and *.bat and *.exe file?
So I know file follow that is like a program.
- *bat, *cmd - Batch, Comand
- *exe - C
- *jar - Java
I can read, understand script content in the *bat file.
2. Why don't use *exe instead *sh, *bat file to run ?
3. How the structure is in *bat, *sh, *exe file ?

A .bat file is a windows batch file it contains a sequence of windows/dos commands. These cannot be used in a Unix shell prompt.
A .sh file is a unix shell script it contains a series of unix commands. These cannot be ran in a Windows DOS or Powershell prompt.
An .exe is windows-only executable format, which may in-turn execute a .bat script or other compiled code. Also cannot be directly used in a Unix prompt.
Each can easily launch a series of commands, or a single command that requires complex environment variables or arguments. You can open a .bat file or the .sh file in a text editor like notepad and view the commands they're running.

Related

how to run multiple command inside other terminal using batch file

i am using nvs, and there is a nvs command line using which i can change my node version.
currently i am using .bat file from Desktop and then go to nvs terminal
cd C:\nvs
start "C:\nvs\nvs.cmd"
this opens the terminal, and then i need to type more commands inside nvs terminal like
nvs use node/10.16.3/x64
cd ../code/api
node -v
code .
i need to automate this and all the executables to be part of the .bat file.
i tried using /c or /k to concatenate the commands. but the terminal closes before executing anything. how to run these commands as a part of batch file together.

How can I run batch in a shell?

I want to have a batch file that opens the command prompt, launches the iex shell within it and then starts my elixir program. The issue I'm having is that as soon as I invoke iex -S mix, which compiles the code and opens the elixir shell, then I am unable to write more commands into it.
:: Start iex and compile with mix
iex -S mix
:: Start elevators
Elevator.Supervisor.start
pause
The last part Elevator.Supervisor.start never runs, for some reason. I guess this is because I opened a shell within the command prompt. Is there a way to feed commands into the iex?
TL;DR use .iex.exs file which is loaded by iex upon start.
Create a file named .iex.exs in the project directory root with the content you want to be run:
Elevator.Supervisor.start()
remove any reference to elixir code (which is now located in .iex.exs) from your .bat file
run .bat file
enjoy.

Execute a .bat file

I am trying to execute a .bat file from a command line inside an automation program. I have written a .bat file that works when double clicked but the automation app will not execute the file.
Is there a command that can be included in the .bat file to make it execute when the automation program calls it up? Here is the .bat file I wrote:
[LITE BOX HI (BOTH LOW & MEDIUM) - ON]
cd..
cd..
cd C:\denkovi\drcltjarorg\
java -jar denkovirelaycommandlinetool.jar DAE001x0 8 4 1
java -jar denkovirelaycommandlinetool.jar DAE001x0 8 6 1
Thanks for any ideas.
Ron
First try adding "pause" to the bottom of the BAT script to see if there are any errors.
Also verify if the path of the executable you are calling is in the PATH variable for the computer.
Make sure the relevant JAR's are in the correct directory.

run bat files in multiple command windows (dos shells)

I am new to working with bat files.
I have a program that basically does the following:
Write multiple bat files in different sub-folders inside a single main folder at once
The program itself utilizes a command :
"start bat_file_name"
( where bat_file_name is derived from the code say bat1,bat2,bat3)
With this the bat files are executed sequentially one after another in single shell. Is there any modification to the above command with which I can run those bat files in different shells or basically run the files in parallel in separate shells?
Any ideas would be helpful.Thanks.
The start command should already do what you need. I've just tried it here and several start commands in a batch file ran in parallel.

How to run several batch files without open shell windows?

I've got some .bat files with start xxx and I need to run them all in another file
so if do start xxx.bat there I will get running xxx and command line shell. I don't need another shell so how to run batch file without opening another shell? or close it's shell after executing.
If I understand correctly, you just want to use call instead of start.
Example:
call xxx.bat

Resources