I'm new to batch and I haven't mastered the syntax yet, I want to know what exactly the following bat does that runs a stress test on a web service.
if [%1] NEQ [] goto connumclientes
estresador 5 -jar estresador.jar Client
goto fin
:connumclientes
if [%2] NEQ [] goto connumsolicitudes
estresador %1 -jar estresador.jar Client
goto fin
:connumsolicitudes
if [%3] NEQ [] goto conrmihost
estresador %1 -jar estresador.jar Client %2
goto fin
:conrmihost
estresador %1 -jar estresador.jar Client %2 %3
:fin
What do the numbers with the symbol mean %
?
This symbol allows access to the parameters with which you start your scripts, for example:
test.bat file
When running the script from the command line:
We can see that it
%0
is reserved for retrieving the full path of the running script and the consecutive numbers will allow retrieving the next parameters that you throw, that is, the first parameter supplied will be%1
, the second will be,%2
and so on.Learn more about how to manipulate these operators: Command Line arguments (Parameters)
Based on the above, we can know that the script evaluates what parameters are supplied in order to know what command to execute.
To do this, it performs a validation using IF in conjunction with the NEQ comparator to verify if the parameter was sent.
If all 3 parameters are supplied the line will be executed: