source: main/trunk/greenstone3/IPv4.bat@ 30036

Last change on this file since 30036 was 30036, checked in by ak19, 9 years ago

Scripts for adding in the IPv4 of the GS server machine into the solr.xml tomcat context file, so that even if they're not using localhost but the hostname of the machine, the /solr context still works off 8383 (host:port/solr).

  • Property svn:executable set to *
File size: 1.1 KB
Line 
1@echo off
2for /f "usebackq tokens=2 delims=:" %%a in (`ipconfig ^| find "IPv4"`) do (set result=%%a)
3
4:: To lop off extra space in front of IPv4 number, end with:
5::do (set result=%a& echo %result:~1%)
6:: Alternative: for /f "tokens=2 delims=:" %a in ('ipconfig ^| findstr /C:"IPv4 Address"') do echo %a
7:: still need to remove space up front for that too.
8
9:: removes extra space in front
10set result=%result:~1%
11
12:: The above produces the IPv4 number, e.g. 100.200.300.45
13:: Still need to replace . with \.
14:: http://scripts.dragon-it.co.uk/scripts.nsf/docs/batch-search-replace-substitute!OpenDocument&ExpandSection=3&BaseTarget=East&AutoFramed
15:: Syntax: %string:SEARCH=REPLACE%
16set result=%result:.=\.%
17
18:: http://stackoverflow.com/questions/2541767/what-is-the-proper-way-to-test-if-variable-is-empty-in-a-batch-file-if-not-1
19:: Make sure it is not the empty string or a string of spaces
20:: Test by setting result to space
21::set result=
22set result=%result: =%
23
24::if not "%result%" == ""
25::set result=^|%result%
26
27:: Echo a vertical bar up front, regardless of whether the result is empty
28echo ^|%result%
Note: See TracBrowser for help on using the repository browser.