Package script print the command to be executed, not execute

Is it possible to install the cmd.exe shell / batch file to print what will be executed, but will not actually execute it?

For example, given a batch file that takes some arguments, some other batch files are selected based on these arguments to run, these batch files execute some commands, or may not call other files / commands, etc.

I would like to be able to run a top-level batch file with all possible combinations of its input arguments and capture what each arg combination will do - without actually trying to execute it.

eg. I would like to be able to conceptually create 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 a list of everything that should be done when running mybatchfile.bat 99 3 42 (NOT the output from executing these commands)

If this cannot be done only with cmd.exe, you can somehow achieve this by running the script package in the cygwin bash shell

0
source share
2 answers

In bash, we will use something like -x to output all possible commands without executing them. how to make bash scripts print each command before execution . The problem is that, as far as I know, there is no exact equivalent command for batch scripts. I would suggest you try:

 @echo on 

at the beginning of your script and:

 @echo off 

at the end of your script, the best place to start.

+1
source

If you never want the batch file to actually execute commands, you can insert echo before each command. This is not an ideal solution by any means, but it can be a workaround for fairly simple scripts.

0
source

Source: https://habr.com/ru/post/1245024/


All Articles