Index: /main/trunk/greenstone3/bin/script/IPv4.bat
===================================================================
--- /main/trunk/greenstone3/bin/script/IPv4.bat	(revision 30037)
+++ /main/trunk/greenstone3/bin/script/IPv4.bat	(revision 30038)
@@ -1,6 +1,11 @@
 @echo off
+
+rem This script will echo the IPv4 of this windows machine. E.g. 100.200.300.45
+rem If passed -format-for-tomcat-context, it will echo the same with a pipe
+rem symbol up front and all the . escaped with a "\". E.g. "|100\.200\.300\.45"
+
 for /f "usebackq tokens=2 delims=:" %%a in (`ipconfig ^| find "IPv4"`) do (set result=%%a)
 
-:: To lop off extra space in front of IPv4 number, end with:
+:: To lop off the single extra space in front of IPv4 number, end with:
 ::do (set result=%a& echo %result:~1%)
 :: Alternative: for /f "tokens=2 delims=:" %a in ('ipconfig ^| findstr /C:"IPv4 Address"') do echo %a
@@ -11,4 +16,10 @@
 
 :: The above produces the IPv4 number, e.g. 100.200.300.45
+
+
+rem Check if we're requested to format the IPv4 for the solr.xml tomcat context file
+if [%1]==[] goto done
+if not "%1"=="-format-for-tomcat-context" goto done
+
 :: Still need to replace . with \.
 :: http://scripts.dragon-it.co.uk/scripts.nsf/docs/batch-search-replace-substitute!OpenDocument&ExpandSection=3&BaseTarget=East&AutoFramed
@@ -25,4 +36,11 @@
 ::set result=^|%result%
 
+echo ^|%result%
+goto fin
+
+
+:done
 :: Echo a vertical bar up front, regardless of whether the result is empty
-echo ^|%result%
+echo %result%
+
+:fin
Index: /main/trunk/greenstone3/bin/script/IPv4.sh
===================================================================
--- /main/trunk/greenstone3/bin/script/IPv4.sh	(revision 30037)
+++ /main/trunk/greenstone3/bin/script/IPv4.sh	(revision 30038)
@@ -1,3 +1,7 @@
 #!/bin/bash
+
+# This script will echo the IPv4 of this unix machine. E.g. 100.200.300.45
+# If passed -format-for-tomcat-context, it will echo the same with a pipe
+# symbol up front and all the . escaped with a "\". E.g. "|100\.200\.300\.45"
 
 #http://www.wikihow.com/Find-Your-IP-Address-on-a-Mac#Finding_Your_Internal_IP_Using_the_Terminal_sub
@@ -11,25 +15,29 @@
 #echo `ifconfig | grep "inet " | grep -v 127.0.0.1`|cut -d' ' -f 2|cut -d':' -f 2
 
-
 tmp=`ifconfig | grep "inet " | grep -v 127.0.0.1`
 
 tmp=`echo $tmp|cut -d' ' -f 2|cut -d':' -f 2`
 
-#http://stackoverflow.com/questions/13210880/replace-one-substring-for-another-string-in-shell-script
-#${original_string//searchterm/$string_to_replace_searchterm_with}
-replace="."
-replacement="\."
+# if requested to format the IPv4 for the solr.xml tomcat context file
+if [ "$1" == "-format-for-tomcat-context" ]; then
 
-tmp=${tmp//$replace/$replacement}
+    #http://stackoverflow.com/questions/13210880/replace-one-substring-for-another-string-in-shell-script
+    #${original_string//searchterm/$string_to_replace_searchterm_with}
+    replace="."
+    replacement="\."
+    
+    tmp=${tmp//$replace/$replacement}
+    
+    # next, if the tmp variable is not the empty string, prefix the | operator
+    # http://unix.stackexchange.com/questions/146942/how-can-i-test-if-a-variable-is-empty-or-contains-only-spaces
+    # Can just return | if $tmp is empty, as that doesn't really matter. Will be consistent with windows
+    if [[ ! -z "${tmp// }" ]]; then
+	tmp="|$tmp"
+    else
+	tmp="|"
+    fi
 
-# next, if the tmp variable is not the empty string, prefix the | operator
-# http://unix.stackexchange.com/questions/146942/how-can-i-test-if-a-variable-is-empty-or-contains-only-spaces
-# Can just return | if $tmp is empty, as that doesn't really matter. Will be consistent with windows
-if [[ ! -z "${tmp// }" ]]; then
-	tmp="|$tmp"
-else
-	tmp="|"
 fi
 
+echo $tmp
 
-echo $tmp
Index: /main/trunk/greenstone3/build.xml
===================================================================
--- /main/trunk/greenstone3/build.xml	(revision 30037)
+++ /main/trunk/greenstone3/build.xml	(revision 30038)
@@ -1414,11 +1414,4 @@
 
   </target>  
-
-  <target name="test-ipv4">
-    <exec executable="${basedir}/bin/script/IPv4.sh" os="${os.unix}" failonerror="false" outputproperty="ipv4.val"/>
-    <exec executable="${basedir}/IPv4.bat" osfamily="windows" failonerror="false" outputproperty="ipv4.val"/>
-    <echo>IPv4 was: ${ipv4.val}</echo>
-  </target>
-  
   
   <target name="configure-tomcat" depends="init,configure-tomcat-local,configure-tomcat-external"/>
@@ -1435,8 +1428,12 @@
 
     <!-- set up the solr context -->
-    
-    <exec executable="${basedir}/bin/script/IPv4.sh" os="${os.unix}" failonerror="false" outputproperty="ipv4.val"/>
-    <exec executable="${basedir}/bin/script/IPv4.bat" osfamily="windows" failonerror="false" outputproperty="ipv4.val"/>
-
+
+    <!-- First work out the IPv4 address for this machine -->
+    <exec executable="${basedir}/bin/script/IPv4.sh" os="${os.unix}" failonerror="false" outputproperty="ipv4.val">
+      <arg value="-format-for-tomcat-context"/>
+    </exec>
+    <exec executable="${basedir}/bin/script/IPv4.bat" osfamily="windows" failonerror="false" outputproperty="ipv4.val">
+      <arg value="-format-for-tomcat-context"/>
+    </exec>
 
     <copy file="${basedir}/ext/solr/solr-tomcat-context.xml.in" tofile="${packages.home}/tomcat/conf/Catalina/localhost/solr.xml" overwrite="true">
