Show
Ignore:
Timestamp:
12.05.2016 17:42:40 (4 years ago)
Author:
ak19
Message:

Fixing up the wget command issued by servercontrol.pm so that it will work on Windows too. Ampersands in URL to wget need to be escaped to work in a subshell. For linux, nesting the ampersand in single quotes suffices. For windows, preceding the ampersand with a hat sign seems to work from DOS prompt. But nesting the entire wget command inside double quotes seems to work on both OS systems.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/servercontrol.pm

    r30530 r30531  
    133133    } 
    134134    else { 
    135     # ampersands need to be escaped with single quotes 
     135    # ampersands need to be escaped  
     136    # - with single quotes around it for linux for the cmd to run in bash subshell 
     137    # - with a ^ before it on windows for the cmd to run in a DOS prompt subshell 
     138    # - or the entire wget command should be nested double quotes (single quotes don't work on windows) 
    136139    my $wgetCommand = $command; 
    137     $wgetCommand =~ s@&@'&'@g; 
    138140 
    139141    my $wget_file_path = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "bin", $ENV{'GSDLOS'}, "wget"); 
     
    145147    # Searching for "perl backtick operator redirect stderr to stdout": 
    146148    # http://www.perlmonks.org/?node=How%20can%20I%20capture%20STDERR%20from%20an%20external%20command%3F 
    147     $wgetCommand = "\"$wget_file_path\" --output-document=- -T 5 -t 1 $library_url$wgetCommand 2>&1";    
    148     #$wgetCommand = "\"$wget_file_path\" --spider -T 5 -t 1 $library_url$wgetCommand 2>&1"; # won't save page 
     149    $wgetCommand = "\"$wget_file_path\" --output-document=- -T 5 -t 1 \"$library_url$wgetCommand\" 2>&1";    
     150    #$wgetCommand = "\"$wget_file_path\" --spider -T 5 -t 1 \"$library_url$wgetCommand\" 2>&1"; # won't save page 
    149151    my $response_content = `$wgetCommand`; 
    150152    my $response_code = undef;