Last change
on this file since 30038 was 30038, checked in by ak19, 9 years ago |
Modified IPv4 scripts to take the parameter -format-for-tomcat-context if it needs to format the IPv4 address. If not passed this flag, it will return the IPv4 address unformatted. build.xml is now updated to pass this flag to the scripts.
|
-
Property svn:executable
set to
*
|
File size:
1.6 KB
|
Line | |
---|
1 | @echo off
|
---|
2 |
|
---|
3 | rem This script will echo the IPv4 of this windows machine. E.g. 100.200.300.45
|
---|
4 | rem If passed -format-for-tomcat-context, it will echo the same with a pipe
|
---|
5 | rem symbol up front and all the . escaped with a "\". E.g. "|100\.200\.300\.45"
|
---|
6 |
|
---|
7 | for /f "usebackq tokens=2 delims=:" %%a in (`ipconfig ^| find "IPv4"`) do (set result=%%a)
|
---|
8 |
|
---|
9 | :: To lop off the single extra space in front of IPv4 number, end with:
|
---|
10 | ::do (set result=%a& echo %result:~1%)
|
---|
11 | :: Alternative: for /f "tokens=2 delims=:" %a in ('ipconfig ^| findstr /C:"IPv4 Address"') do echo %a
|
---|
12 | :: still need to remove space up front for that too.
|
---|
13 |
|
---|
14 | :: removes extra space in front
|
---|
15 | set result=%result:~1%
|
---|
16 |
|
---|
17 | :: The above produces the IPv4 number, e.g. 100.200.300.45
|
---|
18 |
|
---|
19 |
|
---|
20 | rem Check if we're requested to format the IPv4 for the solr.xml tomcat context file
|
---|
21 | if [%1]==[] goto done
|
---|
22 | if not "%1"=="-format-for-tomcat-context" goto done
|
---|
23 |
|
---|
24 | :: Still need to replace . with \.
|
---|
25 | :: http://scripts.dragon-it.co.uk/scripts.nsf/docs/batch-search-replace-substitute!OpenDocument&ExpandSection=3&BaseTarget=East&AutoFramed
|
---|
26 | :: Syntax: %string:SEARCH=REPLACE%
|
---|
27 | set result=%result:.=\.%
|
---|
28 |
|
---|
29 | :: http://stackoverflow.com/questions/2541767/what-is-the-proper-way-to-test-if-variable-is-empty-in-a-batch-file-if-not-1
|
---|
30 | :: Make sure it is not the empty string or a string of spaces
|
---|
31 | :: Test by setting result to space
|
---|
32 | ::set result=
|
---|
33 | set result=%result: =%
|
---|
34 |
|
---|
35 | ::if not "%result%" == ""
|
---|
36 | ::set result=^|%result%
|
---|
37 |
|
---|
38 | echo ^|%result%
|
---|
39 | goto fin
|
---|
40 |
|
---|
41 |
|
---|
42 | :done
|
---|
43 | :: Echo a vertical bar up front, regardless of whether the result is empty
|
---|
44 | echo %result%
|
---|
45 |
|
---|
46 | :fin
|
---|
Note:
See
TracBrowser
for help on using the repository browser.