Changeset 21966 for main


Ignore:
Timestamp:
2010-04-27T14:39:12+12:00 (14 years ago)
Author:
ak19
Message:

Made changes to GLI and gs2-server.bat to allow GLI to deal with spaces in filepath (previously still a problem on Windows when GLI needed to launch gs2-server.bat). The issue was with the windows/batch start command: 1. the way it was launched in GLI and 2. the way windows deals with spaces in the PARAMETERS to the script launched with batch's start cmd. The corresponding changes that needed to be made to deal with these two aspects of the issue are in: gli's greenstone/LocalLibraryServer.java and gs2-server.bat.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/gs2-server.bat

    r20934 r21966  
    152152)
    153153echo.
    154 "%JAVA_EXECUTABLE%" org.greenstone.server.Server2 "%GSDLHOME%" "%serverlang%" %*
    155 ::echo ******* Second argument to gs2-server.bat is: %2
    156 :: The 1st argument to gs2-server.bat (if any) would be --config, the 2nd is the config
    157 :: filename if it is glisite.cfg, then this script was launched through GLI and would
    158 :: have opened a DOS console. Need to exit from this script then to close the console.
    159 if "%2" == "%GSDLHOME%\glisite.cfg" goto quitcmd
     154
     155:: GLI launches gs2-server.bat with:
     156:: cmd /c start "window" "c:\path to\gs2-server.bat" --config=c:\path to\glisite.cfg [--quit=portnum]
     157:: The configfile param could contain spaces, in which case its space-separated parts spread over
     158:: multiple parameters . Need to handle things the following way, since using quotes to embed the
     159:: parameters breaks the start command, see http://ss64.com/nt/start.html
     160:: This script is launched by the start cmd as:
     161:: "c:\path to\gs2-server.bat" --config=c:\path to\config.cfg [--quit=portnum].
     162:: But if the parameter  following --config=<some string> doesn't start with a double hyphen, we
     163:: assume it to be part of the config parameter, as the configfile path may have contained spaces.
     164
     165:: Store all parameters together in config file var: we may or may not have a portnumber
     166:: Get everything after the "--quit=", if anything, and store it in port var.  If no port, nothing to do.
     167set conf=%*
     168set port=%conf:*--quitport=%
     169if "%conf%" == "%port%" (
     170set port=
     171goto :runit
     172) else (
     173set port=%port:~1%
     174)
     175
     176:: Because we got here, need to adjust conf by removing " --quitport=" from it and prefixing this to port
     177call set conf=%%conf:%port%=%%
     178set conf=%conf:~0,-12%
     179set port=--quitport=%port%
     180
     181:: Remove trailing spaces from conf and port
     182:: (We'll put the all-important quotes around conf and port when the actual java cmd is launched)
     183set tmp=%conf%
     184call :trim %tmp%
     185set conf=%tmp%
     186set tmp=%port%
     187call :trim %port%
     188set port=%tmp%
     189set tmp=
     190
     191goto :runit
     192
     193::  http://www.computing.net/answers/programming/dos-batch-remove-trailing-space/9270.html
     194:trim
     195set tmp=%*
     196goto :eof
     197
     198:runit
     199::echo port: %port%& echo conf: %conf%& echo.& echo.
     200:: "%JAVA_EXECUTABLE%" org.greenstone.server.Server2 "%GSDLHOME%" "%serverlang%" %*
     201"%JAVA_EXECUTABLE%" org.greenstone.server.Server2 "%GSDLHOME%" "%serverlang%" "%conf%" "%port%"
     202
     203
     204:: The 1st argument to gs2-server.bat (if any) would be --config, the 2nd is the config filename.
     205:: Both are stored in %conf% now. If the config file is glisite.cfg, then this script was launched through
     206:: GLI and would have opened a DOS console. Need to exit from this script then to close the console.
     207:: Remove --config= prefix and do a case insensitive comparison, since filepaths can have uppercase chars
     208if /i "%conf:~9%" == "%GSDLHOME%\glisite.cfg" goto quitcmd
    160209goto exit
    161210
Note: See TracChangeset for help on using the changeset viewer.