|
Answer» Hi,
I ma trying to port my application from Linux to Windows environment. I have used many shell scripts and makefiles for my system building.
I WANT to know whether every operation done in shell scripts can be ported to a windows batch file. The kind of operations I am looking for are
1. USING for, while loops 2. Declaring functions and local variables 3. Need to know whether the settings (env. variables) made from a batch file is sustained in a cmd window. For example, if i start a cmd window and run a batch file, whether the settings made from the batch files remains after batch file execution.
Regards, Lakshmy 1. Using for, while loops
Batch language has a for command which allows operations over a collection, or thru an iteration. The first operates like a foreach/next loop; the second operates like a for x = y to z by c. There is a goto command to force an early exit from a loop.
2. Declaring functions and local variables
There are no functions in batch code. The closest would be either internal or external subroutines which are executed by a call mechanism. PARAMETERS are passed by reference. Variables are global (SEE #3 below).
3. Need to know whether the settings (env. variables) made from a batch file is sustained in a cmd window. For example, if i start a cmd window and run a batch file, whether the settings made from the batch files remains after batch file execution.
Variables are sustained for the life of the command window session unless otherwise localized by a setlocal statement. Variables created after the setlocal statement live until a endlocal statement is encountered or the batch file ends, whichever comes first. Batch files cannot makes permanent changes to the environment.
Hope this helps.
|