Changeset 31975 for main/trunk
- Timestamp:
- 2017-09-19T18:59:51+12:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/downloaders/WgetDownload.pm
r31957 r31975 40 40 use IO::Select; 41 41 use IO::Socket; 42 use Text::ParseWords; # part of Core modules. Needed to use quotewords() subroutine 42 43 43 44 #use IO::Select qw( ); … … 368 369 # http://www.perlmonks.org/?node_id=394709 and that ends up causing problems in terminating wget, as 2 processes 369 370 # got launched then which don't have parent-child pid relationship (so that terminating one doesn't terminate the other). 370 my @commandargs = split(' ', $cmdWget); 371 unshift(@commandargs, $wget_file_path); 372 $command = "$wget_file_path $cmdWget"; 373 # print STDOUT "Command is: $command\n"; # displayed in GLI output 374 # print STDERR "Command is: $command\n"; # goes into ServerInfoDialog 371 372 # remove leading and trailing spaces, https://stackoverflow.com/questions/4597937/perl-function-to-trim-string-leading-and-trailing-whitespace 373 $cmdWget =~ s/^\s+//; 374 $cmdWget =~ s/\s+$//; 375 376 # split on "words" 377 #my @commandargs = split(' ', $cmdWget); 378 # quotewords: to split on spaces except within quotes, then removes quotes and unescapes double backslash too 379 # https://stackoverflow.com/questions/19762412/regex-to-split-key-value-pairs-ignoring-space-in-double-quotes 380 # https://docstore.mik.ua/orelly/perl/perlnut/c08_389.htm 381 my @commandargs = quotewords('\s+', 0, $cmdWget); 382 unshift(@commandargs, $wget_file_path); # prepend the wget cmd 383 #print STDERR "Command is: ".join(",", @commandargs) . "\n"; # goes into ServerInfoDialog 375 384 376 385 # Wget's output needs to be monitored to find out when it has naturally terminated. … … 639 648 my $wget_file_path = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "bin", $ENV{'GSDLOS'}, "wget"); 640 649 # compose the command as an array for open3, to preserve spaces in any filepath 641 my @commandargs = split(' ', $cmdWget); 642 unshift(@commandargs, $wget_file_path); 643 my $command = "$wget_file_path $cmdWget"; 644 #print STDOUT "Command is: $command\n"; 650 # Do so by removing leading and trailing spaces, then splitting on "words" (preserving spaces in quoted words and removing quotes) 651 $cmdWget =~ s/^\s+//; 652 $cmdWget =~ s/\s+$//; 653 my @commandargs = quotewords('\s+', 0, $cmdWget); 654 unshift(@commandargs, $wget_file_path); # prepend wget cmd to the command array 655 #print STDOUT "Command is: ".join(",", @commandargs) . "\n"; 645 656 646 657 eval { # see p.568 of Perl Cookbook
Note:
See TracChangeset
for help on using the changeset viewer.