batch script print the command that would be executed rather than executing
bash, batch-file, cmd, windows
Solution
In bash we would use something like -x to print out all possible commands without executing them. how to make bash scripts print out every command before executing The problem is that to my knowledge there's no exact equivalent command for Batch Scripts. I would suggest you try placing:
@echo on
at the beginning of your script and:
@echo off
at the end of your script, that's the best starting place.
Problem
Is it possible to set a cmd.exe shell / batch file to print what would be executed but not actually execute it? For example, given a batch file that takes some arguments, based on those arguments selects some other batch files to run, those batch files execute some commands, may or may not call other files/commands etc. I would like to be able to run the top level batch file with all possible combinations of it's input arguments and capture what each arg combination would execute - without actually trying to execute it. e.g. conceptually would want to be able to produce something like: ``` mybatchfile.bat 1 2 3 > mybatchfile_1_2_3.bat mybatchfile.bat 99 3 42 > mybatchfile_99_3_42.bat ``` where mybatchfile_99_3_42.bat is the list of everything that WOULD be executed when running mybatchfile.bat 99 3 42 (NOT the output of executing those commands) If this can't be done solely using cmd.exe is there someway to achieve this by running the batch script in cygwin bash shell