cmd.rst
author Oleksandr Gavenko <gavenkoa@gmail.com>
Tue, 06 Oct 2009 12:38:28 +0300
changeset 215 44ae18f7c0aa
parent 99 0fa8ff78a008
child 216 89e2ee90bc4c
permissions -rw-r--r--
Variable for cmd.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
99
0fa8ff78a008 CMD tricks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     1
-*- outline -*-
0fa8ff78a008 CMD tricks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     2
215
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
     3
* Variables.
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
     4
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
     5
Variable name start with letter and underscore, next chars can be letter,
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
     6
number and underscore. Variable name is case insensitive.
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
     7
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
     8
** List of variables.
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
     9
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    10
  cmd> set
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    11
...
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    12
VAR=VALUE
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    13
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    14
** Getting.
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    15
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    16
Write %VAR% in place where you want insert variable VAr value.
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    17
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    18
** Setting.
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    19
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    20
  cmd> set /p VAR=VALUE
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    21
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    22
VAR is variable name, VALUE is value.
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    23
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    24
** Deleting.
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    25
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    26
  cmd> set VAR=
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    27
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    28
VAR is variable name.
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    29
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    30
*** Input from user.
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    31
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    32
  cmd> set /p VAR=PROMPT
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    33
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    34
VAR is variable name, PROMPT is displayed prompt.
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    35
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    36
*** Input from file.
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    37
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    38
  cmd> set /p VAR=<FILE
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    39
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    40
VAR is variable name, FILE is file name. Sfter executing VAR contain first
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    41
line from FILE.
44ae18f7c0aa Variable for cmd.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 99
diff changeset
    42
99
0fa8ff78a008 CMD tricks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    43
* CMD tricks.
0fa8ff78a008 CMD tricks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    44
0fa8ff78a008 CMD tricks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    45
  $ set /p TOOLOUTPUT= < temp.txt
0fa8ff78a008 CMD tricks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    46
0fa8ff78a008 CMD tricks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    47
  $ for /f "tokens=*" %%i in ('%~dp0sometool.exe') do set TOOLOUTPUT=%%i
0fa8ff78a008 CMD tricks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    48
0fa8ff78a008 CMD tricks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    49
  $ for /f "tokens=1 delims=" %%s in (users.txt) do (echo %%S & command "%%S") >> outputfile.txt