Changeset 24829


Ignore:
Timestamp:
11/30/11 17:48:15 (9 years ago)
Author:
ak19
Message:

Changes to bat files and perl code to deal with brackets in (Windows) filepath. Also checked winmake.bat files to see if changes were needed there. These changes go together with the commits 24826 to 24828 for gems.bat, and commit 24820 on makegs2.bat.

Location:
main/trunk
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/client-gli.bat

    r19391 r24829  
    11@echo off
     2setlocal enabledelayedexpansion
     3
    24pushd "%CD%"
    35CD /D "%~dp0"
     
    9496:: the client side. If we have Perl, pass in GSDLHOME for the -gsdl option and the PERLPATH.
    9597if "%PERLPATH%" == "" goto nogsdl
    96     echo Perl and GSDLHOME (%GSDLHOME%) detected. Downloading is enabled.
     98    echo Perl and GSDLHOME (!GSDLHOME!) detected. Downloading is enabled.
    9799    echo.
    98100    "%JAVA_EXECUTABLE%" -Xmx128M -cp classes/;GLI.jar;lib/apache.jar;lib/qfslib.jar org.greenstone.gatherer.GathererProg -use_remote_greenstone -gsdl "%GSDLHOME%" -perl "%PERLPATH%" %1 %2 %3 %4 %5 %6 %7 %8 %9
     
    124126set PROGABBR=
    125127popd
     128endlocal
  • main/trunk/gli/findjava.bat

    r20655 r24829  
    11@echo off
     2setlocal enabledelayedexpansion
    23
    34:: Environment Variables passed in: _VERSION, GLILANG and possibly also
     
    2122    :: else we look for a compiled version of search4j in a GS installation
    2223    if "%_VERSION%" == "2" (
    23         set SEARCH4J_EXECUTABLE=%GSDLHOME%\bin\windows\search4j.exe
    24         set HINT=%GSDLHOME%\packages\jre
     24        set SEARCH4J_EXECUTABLE=!GSDLHOME!\bin\windows\search4j.exe
     25        set HINT=!GSDLHOME!\packages\jre
    2526    )
    26         if "%_VERSION%" == "3" (
    27         set SEARCH4J_EXECUTABLE=%GSDL3SRCHOME%\bin\search4j.exe
    28         set HINT=%GSDL3SRCHOME%\packages\jre
     27    if "%_VERSION%" == "3" (
     28        set SEARCH4J_EXECUTABLE=!GSDL3SRCHOME!\bin\search4j.exe
     29        set HINT=!GSDL3SRCHOME!\packages\jre
    2930    )
    3031    if not exist "%SEARCH4J_EXECUTABLE%" goto tryJava
    3132
    32 :setJexec   
     33:setJexec
    3334    "%SEARCH4J_EXECUTABLE%" -e -m "%MIN_VERSION%" -p "%HINT%" | winutil\setvar.exe JAVA_EXECUTABLE > %TMP%\set_java_executable.bat
    3435    call "%TMP%\set_java_executable.bat"
     
    5657            echo WARNING:
    5758        echo Java Runtime not bundled with this Greenstone installation.
    58         echo Using JAVA_HOME: %JAVA_HOME%
     59        echo Using JAVA_HOME: !JAVA_HOME!
    5960        echo ^(NOTE: this needs to be %DISPLAY_MIN_VERSION% or higher.^)
    6061        echo ***************************************************************************
     
    9798set MIN_VERSION=
    9899set DISPLAY_MIN_VERSION=
     100
     101endlocal & set JAVA_EXECUTABLE=%JAVA_EXECUTABLE%& set GS_JAVA_HOME=%GS_JAVA_HOME%
  • main/trunk/gli/gli.bat

    r23650 r24829  
    11@echo off
     2setlocal enabledelayedexpansion
     3
    24color 0A
    35set startdir=%CD%
     
    4850    echo.
    4951    echo Checking if the Greenstone collection directory is writable ...
    50     (echo This is a temporary file. It is safe to delete it. > "%GSDLHOME%\collect\testing.tmp" ) 2>nul
     52    (echo This is a temporary file. It is safe to delete it. > "!GSDLHOME!\collect\testing.tmp" ) 2>nul
    5153    if exist "%GSDLHOME%\collect\testing.tmp" goto deleteTempFile
    5254    if "%1" == "Elevated" goto printWarning
    5355    echo ... FAILED
    54     echo The %PROGNAME% cannot write to the collection directory (%GSDLHOME%\collect)
     56    echo The %PROGNAME% cannot write to the collection directory (!GSDLHOME!\collect)
    5557    echo Requesting elevated status to become admin user to continue.
    5658    "%GSDLHOME%\bin\windows\gstart.exe" %0 Elevated %1 %2 %3 %4 %5 %6 %7 %8 %9
     
    5961:printWarning
    6062    echo ... FAILED
    61     echo The %PROGNAME% cannot write to the log directory (%GSDLHOME%\collect).
     63    echo The %PROGNAME% cannot write to the log directory (!GSDLHOME!\collect).
    6264    echo Attempting to continue without permissions.
    6365    goto shiftElevated
     
    114116if not "%GSDL3SRCHOME%" == "" (
    115117    echo GSDL3SRCHOME:
    116     echo %GSDL3SRCHOME%
     118    echo !GSDL3SRCHOME!
    117119    echo.
    118120)
     
    120122if not "%GSDL3HOME%" == "" (
    121123    echo GSDL3HOME:
    122     echo %GSDL3HOME%
     124    echo !GSDL3HOME!
    123125    echo.
    124126)
     
    126128if not "%GSDLHOME%" == "" (
    127129    echo GSDLHOME:
    128     echo %GSDLHOME%
     130    echo !GSDLHOME!
    129131    echo.
    130132)
     
    166168:localLib
    167169    if exist "%GSDLHOME%\server.exe" (
    168     set locallib=%GSDLHOME%\server.exe
     170    set locallib=!GSDLHOME!\server.exe
    169171    ) else (
    170     set locallib=%GSDLHOME%\gs2-web-server.bat
     172    set locallib=!GSDLHOME!\gs2-web-server.bat
    171173    )
    172174
     
    211213cd "%startdir%"
    212214set startdir=
     215
     216endlocal
  • main/trunk/gli/makejar.bat

    r24782 r24829  
    11echo off
     2setlocal enabledelayedexpansion
     3
    24pushd "%CD%"
    35CD /D "%~dp0"
     
    115117
    116118  cd jar
    117   "%JARPATH%\jar" xf ..\lib\apache.jar com org
    118   "%JARPATH%\jar" xf ..\lib\qfslib.jar de
     119  "!JARPATH!\jar" xf ..\lib\apache.jar com org
     120  "!JARPATH!\jar" xf ..\lib\qfslib.jar de
    119121
    120122  cd ..
     
    152154
    153155    if not exist appletstore (
    154       "%JARPATH%\keytool" -genkey -alias privateKey -keystore appletstore -storepass greenstone
     156      "!JARPATH!\keytool" -genkey -alias privateKey -keystore appletstore -storepass greenstone
    155157    )
    156158
     
    158160    if exist appletpasswd (
    159161      echo Using jarsigner to make signed jar file ...
    160       "%JARPATH%\jarsigner" -keystore appletstore -signedjar SignedGatherer.jar GLI.jar privateKey < appletpasswd >NUL 2>NUL
     162      "!JARPATH!\jarsigner" -keystore appletstore -signedjar SignedGatherer.jar GLI.jar privateKey < appletpasswd >NUL 2>NUL
    161163      echo ... done.
    162164    ) ELSE (
    163       "%JARPATH%\jarsigner" -keystore appletstore -signedjar SignedGatherer.jar GLI.jar privateKey
     165      "!JARPATH!\jarsigner" -keystore appletstore -signedjar SignedGatherer.jar GLI.jar privateKey
    164166    )
    165167    echo Installing SignedGatherer in ..\bin\java
     
    169171
    170172popd
     173endlocal
  • main/trunk/greenstone2/bin/script/explode_metadata_database.pl

    r24404 r24829  
    412412        my ($field, $value) = (@$pair);
    413413        $field =~ s/^ex\.([^.]+)$/$1/; #remove any ex. iff it's the only metadata set prefix (will leave ex.dc.* intact)
    414         $value =~ s/\\\\/\\/g;
     414        $value =~ s/\\\\/\\/g;         # don't regex brackets () here though!
    415415        my $document_file_full;
    416416
     
    596596    }
    597597    else {
    598         $orig_base_dir =~ s/\\/\\\\/g; # escape windows style slashes for the regex below
     598        $orig_base_dir = &util::filename_to_regex($orig_base_dir); # escape windows style slashes for the regex below       
    599599        if ($document_file_full =~ m/^$orig_base_dir.*/) {
    600600        # file local to metadata record
  • main/trunk/greenstone2/bin/script/schedule.pl

    r21292 r24829  
    208208    $os = $ENV{'GSDLOS'};
    209209    $path = $ENV{'PATH'};
     210   
     211    if("$gsdl" =~ m/(\\\(|\\\)| )/ ) { # () brackets or spaces in path
     212        &gsprintf($out, "\n\n{schedule.filepath_warning}\n\n\n", $gsdl);
     213    }
    210214
    211215    my $service = "schedule";
  • main/trunk/greenstone2/bin/script/wvware.pl

    r24599 r24829  
    333333    my $safe_reg_expression = $assoc_dir_path;
    334334    $safe_reg_expression =~ s/\\/\\\\/g;
     335    $safe_reg_expression =~ s@\(@\\(@g; # escape brackets
     336    $safe_reg_expression =~ s@\)@\\)@g; # escape brackets
    335337    $safe_reg_expression =~ s/\./\\./g;
    336338    $safe_reg_expression =~ s/\-/\\-/g;
  • main/trunk/greenstone2/findjava.bat

    r20816 r24829  
    11@echo off
     2
     3setlocal enabledelayedexpansion
    24
    35:: Environment Variables passed in: _VERSION, GLILANG and possibly also
     
    2123    :: else we look for a compiled version of search4j in a GS installation
    2224    if "%_VERSION%" == "2" (
    23         set SEARCH4J_EXECUTABLE=%GSDLHOME%\bin\windows\search4j.exe
    24         set HINT=%GSDLHOME%\packages\jre
     25        set SEARCH4J_EXECUTABLE=!GSDLHOME!\bin\windows\search4j.exe
     26        set HINT=!GSDLHOME!\packages\jre
    2527    )
    2628    if "%_VERSION%" == "3" (
    27         set SEARCH4J_EXECUTABLE=%GSDL3SRCHOME%\bin\search4j.exe
    28         set HINT=%GSDL3SRCHOME%\packages\jre
     29        set SEARCH4J_EXECUTABLE=!GSDL3SRCHOME!\bin\search4j.exe
     30        set HINT=!GSDL3SRCHOME!\packages\jre
    2931    )
    3032    if not exist "%SEARCH4J_EXECUTABLE%" goto tryJava
     
    5658            echo WARNING:
    5759        echo Java Runtime not bundled with this Greenstone installation.
    58         echo Using JAVA_HOME: %JAVA_HOME%
     60        echo Using JAVA_HOME: !JAVA_HOME!
    5961        echo ^(NOTE: this needs to be %DISPLAY_MIN_VERSION% or higher.^)
    6062        echo ***************************************************************************
     
    9799set MIN_VERSION=
    98100set DISPLAY_MIN_VERSION=
     101
     102endlocal & set JAVA_EXECUTABLE=%JAVA_EXECUTABLE%& set GS_JAVA_HOME=%GS_JAVA_HOME%
  • main/trunk/greenstone2/gs2-server.bat

    r22687 r24829  
    11@echo off
     2setlocal enabledelayedexpansion
     3
    24pushd "%CD%"
    35CD /D "%~dp0"
     
    810    echo Checking if the Greenstone log directory is writable ...
    911    if not exist "%GSDLHOME%\etc\logs-gsi" goto missingLogDir
    10     (echo This is a temporary file. It is safe to delete it. > "%GSDLHOME%\etc\logs-gsi\testing.tmp" ) 2>nul
     12    (echo This is a temporary file. It is safe to delete it. > "!GSDLHOME!\etc\logs-gsi\testing.tmp" ) 2>nul
    1113    if exist "%GSDLHOME%\etc\logs-gsi\testing.tmp" goto deleteTempFile
    1214    if "%1" == "Elevated" goto printWarning
    1315    echo ... FAILED
    14     echo The Greenstone server cannot write to the log directory (%GSDLHOME%\etc\logs-gsi)
     16    echo The Greenstone server cannot write to the log directory (!GSDLHOME!\etc\logs-gsi)
    1517    echo Requesting elevated status to become admin user to continue.
    1618    "%GSDLHOME%\bin\windows\gstart.exe" %0 Elevated %1 %2 %3 %4 %5 %6 %7 %8 %9
     
    1921:missingLogDir
    2022    echo ... FAILED
    21     echo The Greenstone log directory does not exist (%GSDLHOME%\etc\logs-gsi). Please either create this directory or reinstall Greenstone.
     23    echo The Greenstone log directory does not exist (!GSDLHOME!\etc\logs-gsi). Please either create this directory or reinstall Greenstone.
    2224    pause
    2325    goto done
     
    2527:printWarning
    2628    echo ... FAILED
    27     echo The Greenstone server cannot write to the log directory (%GSDLHOME%\etc\logs-gsi).
     29    echo The Greenstone server cannot write to the log directory (!GSDLHOME!\etc\logs-gsi).
    2830    echo Attempting to continue without permissions.
    2931    goto shiftElevated
     
    5254:done
    5355popd
     56endlocal
  • main/trunk/greenstone2/gs2-web-server.bat

    r24508 r24829  
    11@echo off
    2 SETLOCAL
     2SETLOCAL enabledelayedexpansion
    33
    44if "%serverlang%" == "" set serverlang=en
     
    2121:: Some users may set the above line manually
    2222if "%gsdl2path%" == "" (
    23    set GSDLHOME=%CD%
    24    set gsdl2path=%CD%
     23   set GSDLHOME=!CD!
     24   set gsdl2path=!CD!
    2525)
    2626
     
    2929    echo Checking if the Greenstone log directory is writable ...
    3030    if not exist "%GSDLHOME%\etc\logs-gsi" goto missingLogDir
    31     (echo This is a temporary file. It is safe to delete it. > "%GSDLHOME%\etc\logs-gsi\testing.tmp" ) 2>nul
     31    (echo This is a temporary file. It is safe to delete it. > "!GSDLHOME!\etc\logs-gsi\testing.tmp" ) 2>nul
    3232    if exist "%GSDLHOME%\etc\logs-gsi\testing.tmp" goto deleteTempFile 
    3333    if "%1" == "Elevated" goto printWarning
    3434    echo ... FAILED
    35     echo The Greenstone server cannot write to the log directory (%GSDLHOME%\etc\logs-gsi)
     35    echo The Greenstone server cannot write to the log directory (!GSDLHOME!\etc\logs-gsi)
    3636    echo Requesting elevated status to become admin user to continue.
    3737    "%GSDLHOME%\bin\windows\gstart.exe" %0 Elevated %1 %2 %3 %4 %5 %6 %7 %8 %9
     
    4040:missingLogDir
    4141    echo ... FAILED
    42     echo The Greenstone log directory does not exist (%GSDLHOME%\etc\logs-gsi). Please reinstall Greenstone.
     42    echo The Greenstone log directory does not exist (!GSDLHOME!\etc\logs-gsi). Please reinstall Greenstone.
    4343    pause
    4444    goto exit
     
    4646:printWarning
    4747    echo ... FAILED
    48     echo The Greenstone server cannot write to the log directory (%GSDLHOME%\etc\logs-gsi).
     48    echo The Greenstone server cannot write to the log directory (!GSDLHOME!\etc\logs-gsi).
    4949    echo Attempting to continue without permissions.
    5050    goto shiftElevated
     
    6464:: If either GSDLHOME or GSDLOS is not set, need to run setup.bat first
    6565:: OR operations in an IF stmt: http://fixunix.com/ms-dos/21057-how-implement-if-condition-batch-file.html
    66 for %%i in ("%GSDLOS%" "%GSDLHOME%") do if %%i == "" set OR=True
     66for %%i in ("!GSDLOS!" "!GSDLHOME!") do if %%i == "" set OR=True
    6767if "%OR%" == "True" (
    68    pushd "%gsdl2path%"
     68   pushd "!gsdl2path!"
    6969   call setup.bat
    7070rem   echo **** GSDLOS: %GSDLOS% and GSDLHOME: %GSDLHOME%
     
    9797if exist "%GSDLHOME%\llssite.cfg" goto cfgfile
    9898if exist "%GSDLHOME%\llssite.cfg.in" (
    99    copy "%GSDLHOME%\llssite.cfg.in" "%GSDLHOME%\llssite.cfg"
     99   copy "!GSDLHOME!\llssite.cfg.in" "!GSDLHOME!\llssite.cfg"
    100100) else (
    101101   echo Warning: could not find llssite.cfg.in to create llssite.cfg from.
     
    129129if not "%CLASSPATH%" == "" if not "%CLASSPATH%" == "%test_cpath%" (
    130130   echo   - CLASSPATH already correct:
    131    echo %CLASSPATH%
     131   echo !CLASSPATH!
    132132   goto :eof
    133133)
     
    173173   echo.
    174174   echo Server log messages go to:
    175    echo    "%GSDLHOME%\etc\logs-gsi\server.log"
     175   echo    "!GSDLHOME!\etc\logs-gsi\server.log"
    176176   echo.
    177177   echo Using Apache web server located at:
    178    echo    "%GSDLHOME%\apache-httpd\%GSDLOS%\bin\httpd"
     178   echo    "!GSDLHOME!\apache-httpd\!GSDLOS!\bin\httpd"
    179179   echo The Apache error log is at:
    180    echo    "%GSDLHOME%\apache-httpd\%GSDLOS%\logs\error_log"
     180   echo    "!GSDLHOME!\apache-httpd\!GSDLOS!\logs\error_log"
    181181   echo The Apache configuration file template is at:
    182    echo    "%GSDLHOME%\apache-httpd\%GSDLOS%\conf\httpd.conf.in"
     182   echo    "!GSDLHOME!\apache-httpd\!GSDLOS!\conf\httpd.conf.in"
    183183   echo This is used to generate:
    184    echo    "%GSDLHOME%\apache-httpd\%GSDLOS%\conf\httpd.conf"
     184   echo    "!GSDLHOME!\apache-httpd\!GSDLOS!\conf\httpd.conf"
    185185   echo    each time Enter Library is pressed or otherwise activated.
    186186   echo ***************************************************************
  • main/trunk/greenstone2/gsicontrol.bat

    r24819 r24829  
    11@echo off
    22
    3 setlocal
     3setlocal enabledelayedexpansion
     4
    45::set testdone=0
    56set startdir=%CD%
     
    2526:: directory (after replacing spaces, colons and backslashes)
    2627set signal=%GSDLHOME: =_%
    27 for /F "delims=*" %%T in ('"echo %signal%| %_sed% s@[\\:]@_@g"') do set signal=%%T
     28for /F "delims=*" %%T in ('"echo !signal!| !_sed! s@[\\:]@_@g"') do set signal=%%T
    2829set GS2_APACHE_HTTPD_SIGNAL=GS2_APACHE_HTTPD_%signal%
    2930set signal=
     
    164165    echo ^<enabled^>true
    165166    echo ^<groups^>administrator,colbuilder,all-collections-editor
    166     echo ^<password^>%encrypted_password%
     167    echo ^<password^>!encrypted_password!
    167168    echo ^<username^>admin
    168     ) > "%GSDLHOME%\etc\users.txt"
    169     type "%GSDLHOME%\etc\users.txt" | txt2db -append "%GSDLHOME%\etc\users.gdb"
    170     del "%GSDLHOME%\etc\users.txt" 
     169    ) > "!GSDLHOME!\etc\users.txt"
     170    type "!GSDLHOME!\etc\users.txt" | txt2db -append "!GSDLHOME!\etc\users.gdb"
     171    del "!GSDLHOME!\etc\users.txt" 
    171172) else (
    172173    echo Did not set password
     
    185186
    186187set gshome=
    187 FOR /F "tokens=*" %%G IN ('findstr /R ^gsdlhome "%GSDLHOME%\%cgibin%\gsdlsite.cfg"') do (call :concat %%G)
     188FOR /F "tokens=*" %%G IN ('findstr /R ^gsdlhome "!GSDLHOME!\!cgibin!\gsdlsite.cfg"') do call :concat %%G
    188189
    189190:: The following doesn't work if there are spaces in the gsdlhome filepath
    190 ::FOR /F "tokens=2" %%G IN ('findstr /R ^gsdlhome "%GSDLHOME%\%cgibin%\gsdlsite.cfg"') do set gshome=%%G
     191::FOR /F "tokens=2" %%G IN ('findstr /R ^gsdlhome "!GSDLHOME!\!cgibin!\gsdlsite.cfg"') do set gshome=%%G
    191192:: before string comparison, remove any quotes around gsdlhome value defined in config file
    192193:: if not [%gshome%] == [] set gshome=%gshome:"=%
     
    201202:: The path to the included perl at the top of gliserver.pl needs to use the new gsdlhome
    202203:: On windows, the path in gliserver.pl uses backslashes
    203 for /F "delims=*" %%T in ('"echo %gshome%| %_sed% s@\\@\\\\@g"') do set safeoldhome=%%T
    204 for /F "delims=*" %%T in ('"echo %gsdlhome%| %_sed% s@\\@\\\\@g"') do set safenewhome=%%T
     204for /F "delims=*" %%T in ('"echo !gshome!| !_sed! s@\\@\\\\@g"') do set safeoldhome=%%T
     205for /F "delims=*" %%T in ('"echo !gsdlhome!| !_sed! s@\\@\\\\@g"') do set safenewhome=%%T
    205206if exist "%GSDLHOME%\bin\%GSDLOS%\perl" (
    206   copy "%cgibin%\gliserver.pl" "%cgibin%\gliserver.pl.bak"
    207   type "%cgibin%\gliserver.pl.bak" | %_sed% "s@%safeoldhome%@%safenewhome%@g" > "%cgibin%\gliserver.pl"
    208   del "%cgibin%\gliserver.pl.bak"
     207  copy "!cgibin!\gliserver.pl" "!cgibin!\gliserver.pl.bak"
     208  type "!cgibin!\gliserver.pl.bak" | !_sed! "s@!safeoldhome!@!safenewhome!@g" > "!cgibin!\gliserver.pl"
     209  del "!cgibin!\gliserver.pl.bak"
    209210)
    210211set safenewhome=
     
    212213set gshome=
    213214
    214 for /F "delims=*" %%T in ('"echo %GSDLHOME%| %_sed% s@\\@\/@g"') do set safepath=%%T
     215for /F "delims=*" %%T in ('"echo !GSDLHOME!| !_sed! s@\\@\/@g"') do set safepath=%%T
    215216
    216217:: Also re-initialise the log4j.properties and force regeneration of
     
    247248echo. >> "%cgibin%\gsdlsite.cfg"
    248249
    249 for /F "delims=*" %%T in ('"echo %GSDLHOME%| %_sed% s@\\@\\\\@g"') do set safepath=%%T
     250for /F "delims=*" %%T in ('"echo !GSDLHOME!| !_sed! s@\\@\\\\@g"') do set safepath=%%T
    250251%_sed% "s@\*\*GSDLHOME\*\*@\"%safepath%\"@g" "%cgibin%\gsdlsite.cfg.in" >> "%cgibin%\gsdlsite.cfg"
    251252set safepath=
     
    266267::configure-apache
    267268:cfgapach
    268 if not "%configfile%" == "" if exist "%configfile%" (goto cfgport) else (echo Config file %configfile% does not exist. Using default llssite.cfg)
     269if not "%configfile%" == "" if exist "%configfile%" (goto cfgport) else (echo Config file !configfile! does not exist. Using default llssite.cfg)
    269270
    270271if exist "%GSDLHOME%\llssite.cfg" (
    271   set configfile=%GSDLHOME%\llssite.cfg
     272  set configfile=!GSDLHOME!\llssite.cfg
    272273  goto cfgport
    273274)
    274275if not exist "%GSDLHOME%\llssite.cfg.in" (
    275   echo Unable to proceed as neither %GSDLHOME%\llssite.cfg nor %GSDLHOME%\llssite.cfg.in could be found
     276  echo Unable to proceed as neither !GSDLHOME!\llssite.cfg nor !GSDLHOME!\llssite.cfg.in could be found
    276277  goto exit
    277278)
     
    282283echo Configuring the apache webserver...
    283284:: See http://ss64.com/nt/for_cmd.html, http://ss64.com/nt/findstr.html (and http://ss64.com/nt/find.html)
    284 FOR /F "tokens=2 delims==" %%G IN ('findstr /R ^portnumber "%configfile%"') do set port=%%G
    285 FOR /F "tokens=2 delims==" %%G IN ('findstr /R ^hostIP "%configfile%"') do set hostIP=%%G
    286 FOR /F "tokens=2 delims==" %%G IN ('findstr /R ^hosts "%configfile%"') do set hosts=%%G
    287 FOR /F "tokens=2 delims==" %%G IN ('findstr /R ^externalaccess "%configfile%"') do set allowfromall=%%G
     285FOR /F "tokens=2 delims==" %%G IN ('findstr /R ^portnumber "!configfile!"') do set port=%%G
     286FOR /F "tokens=2 delims==" %%G IN ('findstr /R ^hostIP "!configfile!"') do set hostIP=%%G
     287FOR /F "tokens=2 delims==" %%G IN ('findstr /R ^hosts "!configfile!"') do set hosts=%%G
     288FOR /F "tokens=2 delims==" %%G IN ('findstr /R ^externalaccess "!configfile!"') do set allowfromall=%%G
    288289
    289290if "%allowfromall%" == "1" set allowfromall="Allow"& goto portcon
     
    313314   goto exit
    314315)
    315 if "%safepath%" == "" for /F "delims=*" %%T in ('"echo %GSDLHOME%| %_sed% s@\\@\/@g"') do set safepath=%%T
     316if "%safepath%" == "" for /F "delims=*" %%T in ('"echo !GSDLHOME!| !_sed! s@\\@\/@g"') do set safepath=%%T
    316317
    317318:: Doesn't work if there are spaces in the collecthome path in gsdlsite.cfg
    318 ::if exist "%GSDLHOME%\%cgibin%\gsdlsite.cfg" FOR /F "tokens=2" %%G IN ('findstr /R ^collecthome "%GSDLHOME%\%cgibin%\gsdlsite.cfg"') do set COLLECTHOME=%%G
     319::if exist "%GSDLHOME%\%cgibin%\gsdlsite.cfg" FOR /F "tokens=2" %%G IN ('findstr /R ^collecthome "!GSDLHOME!\!cgibin!\gsdlsite.cfg"') do set COLLECTHOME=%%G
    319320
    320321:: variable in subroutine concat is called gshome,
    321322:: so forced to use it here for collecthome
    322323set gshome=
    323 if exist "%GSDLHOME%\%cgibin%\gsdlsite.cfg" FOR /F "tokens=*" %%G IN ('findstr /R ^collecthome "%GSDLHOME%\%cgibin%\gsdlsite.cfg"') do (call :concat %%G)
     324if exist "%GSDLHOME%\%cgibin%\gsdlsite.cfg" FOR /F "tokens=*" %%G IN ('findstr /R ^collecthome "!GSDLHOME!\!cgibin!\gsdlsite.cfg"') do call :concat %%G
    324325set COLLECTHOME=%gshome%
    325326set gshome=
    326327
    327328if "%COLLECTHOME%" == "" set COLLECTHOME=%GSDLHOME%\collect
    328 for /F "delims=*" %%T in ('"echo %COLLECTHOME%| %_sed% s@\\@\/@g"') do set safecollectpath=%%T
    329 
     329for /F "delims=*" %%T in ('"echo !COLLECTHOME!| !_sed! s@\\@\/@g"') do set safecollectpath=%%T
    330330
    331331echo Port: %port%
  • main/trunk/greenstone2/perllib/inexport.pm

    r24344 r24829  
    10351035
    10361036    $situated_dir =~ s/[\\\/]+$//; # remove tailing slashes
    1037     $situated_dir =~ s/\\/\\\\/g;  # need to protect windows slash \ in regular expression
     1037    $situated_dir = &util::filename_to_regex($situated_dir); # need to escape windows slash \ and brackets in regular expression
    10381038   
    10391039    # Go through existing_files, and mark anything that is contained
  • main/trunk/greenstone2/perllib/plugins/DirectoryPlugin.pm

    r24349 r24829  
    481481    foreach my $ek (@extrametakeys) {
    482482    my ($subdir_re,$extrakey_dir) = &File::Basename::fileparse($ek);
    483     $extrakey_dir =~ s/\\\./\./g; # remove RE syntax for .
    484     $extrakey_dir =~ s/\\\\/\\/g; # remove RE syntax for \
     483    $extrakey_dir = &util::unregex_filename($extrakey_dir);
    485484
    486485    my $dirsep_re = &util::get_re_dirsep();
    487486
    488     my $ek_non_re = $ek;
    489     $ek_non_re =~ s/\\\./\./g; # remove RE syntax for .
    490     $ek_non_re =~ s/\\\\/\\/g; # remove RE syntax for \
     487    my $ek_non_re = &util::unregex_filename($ek);
    491488    if ($ek_non_re =~ m/$dirsep_re/) { # specifies at least one directory
    492489        my $md = $extrametadata{$ek};
  • main/trunk/greenstone2/perllib/plugouts/BasePlugout.pm

    r24404 r24829  
    735735#       if (defined $collect_dir) {
    736736#       my $collect_dir_re_safe = $collect_dir;
    737 #       $collect_dir_re_safe =~ s/\\/\\\\/g;
     737#       $collect_dir_re_safe =~ s/\\/\\\\/g; # use &util::filename_to_regex()
    738738#       $collect_dir_re_safe =~ s/\./\\./g;##
    739739
  • main/trunk/greenstone2/perllib/plugouts/DSpacePlugout.pm

    r24402 r24829  
    300300    $real_filename =~ s/^\\(.*)/$1/i;
    301301    if (-e $real_filename) {
    302         # escape backslashes in path for upcoming regex match
    303         my $escaped_source_filename = $source_filename;
    304         $escaped_source_filename =~ s/\\/\\\\/g;       
     302        # escape backslashes and brackets in path for upcoming regex match
     303        my $escaped_source_filename = &util::filename_to_regex($source_filename);
    305304        if ($real_filename =~ m/$escaped_source_filename$/) {
    306305        next;
  • main/trunk/greenstone2/perllib/plugouts/FedoraMETSPlugout.pm

    r22465 r24829  
    613613   
    614614    my $gsdl_href = &util::filename_cat($working_dir, $fname);
    615     $collectparent =~ s/\\/\\\\/g;            # escape reserved metacharacter \ in path (by replacing it with \\) for substitution
     615    $collectparent = &util::filename_to_regex($collectparent); # escape reserved metacharacter \ in path (by replacing it with \\) for substitution
    616616    $gsdl_href =~ s/^$collectparent(\/|\\)?//; # remove the collectparent path in gsdl_href and any trailing slash
    617617    $gsdl_href =~ s/\\/\//g;                   # make sure we have url paths (which only use / not \)
     
    744744
    745745           my $gsdl_href = &util::filename_cat($working_dir,$assfilePath);
    746            $collectparent =~ s/\\/\\\\/g;            # escape reserved metacharacter \ in path (by replacing it with \\) for substitution
     746           $collectparent = &util::filename_to_regex($collectparent); # escape reserved metacharacter \ in path (by replacing it with \\) for substitution
    747747           $gsdl_href =~ s/^$collectparent(\/|\\)?//; # remove the collectparent path in gsdl_href and any trailing slash
    748748           $gsdl_href =~ s/\\/\//g;                   # make sure we have url paths (which only use / not \)
  • main/trunk/greenstone2/perllib/strings.properties

    r24754 r24829  
    332332schedule.frequency.daily:Re-build every day
    333333schedule.frequency.weekly:Re-build every week
     334schedule.filepath_warning:**** Warning: schedule.pl may not work when Greenstone is installed in a path containing brackets and/or spaces: %s.
    334335schedule.action:How to set up automatic re-building
    335336schedule.action.add:Schedule automatic re-building
  • main/trunk/greenstone2/perllib/util.pm

    r24563 r24829  
    839839    # need to put single backslash back to double so that regex works
    840840    if ($ENV{'GSDLOS'} =~ /^windows$/i) {
    841     $filename =~ s/\\/\\\\/g;
    842     }
     841        $filename =~ s/\\/\\\\/g;
     842    }
     843   
     844    # note that the first part of a substitution is a regex, so RE chars need to be escaped,
     845    # the second part of a substitution is not a regex, so for e.g. full-stop can be specified literally
     846    $filename =~ s/\./\\./g; # in case there are extensions/other full stops, escape them
     847    $filename =~ s@\(@\\(@g; # escape brackets
     848    $filename =~ s@\)@\\)@g; # escape brackets
     849   
     850    return $filename;
     851}
     852
     853sub unregex_filename {
     854    my $filename = shift (@_);
     855
     856    # need to put doubled backslashes for regex back to single
     857    $filename =~ s/\\\\/\\/g; # remove RE syntax for \   
     858    $filename =~ s/\\\./\./g; # remove RE syntax for .
     859    $filename =~ s@\\\(@(@g; # remove RE syntax for ( => "\(" turns into "("
     860    $filename =~ s@\\\)@)@g; # remove RE syntax for ) => "\)" turns into ")"
    843861    return $filename;
    844862}
     
    928946    if ($ENV{'GSDLOS'} =~ /^windows$/i)
    929947    {
    930     my $escaped_val = $val;
    931     $escaped_val =~ s/\\/\\\\/g; # escape any Windows backslashes for upcoming regex
     948    my $escaped_val = &filename_to_regex($val); # escape any Windows backslashes and brackets for upcoming regex
    932949    if (!defined($ENV{$var})) {
    933950        $ENV{$var} = "$val";
     
    953970    if ($ENV{'GSDLOS'} =~ /^windows$/i)
    954971    {
    955     my $escaped_val = $val;
    956     $escaped_val =~ s/\\/\\\\/g; # escape any Windows backslashes for upcoming regex
     972    my $escaped_val = &filename_to_regex($val); # escape any Windows backslashes and brackets for upcoming regex
    957973    if (!defined($ENV{$var})) {
    958974        $ENV{$var} = "$val";
     
    10481064    }
    10491065   
    1050     $within_dir =~ s/\\/\\\\/g; # escape DOS style file separator
    1051 
     1066    $within_dir = &filename_to_regex($within_dir); # escape DOS style file separator and brackets   
    10521067    if ($filename =~ m/^$within_dir(.*)$/) {
    10531068    $filename = $1;
Note: See TracChangeset for help on using the changeset viewer.