diff options
author | 2020-04-30 13:29:38 -0700 | |
---|---|---|
committer | 2020-04-30 13:29:38 -0700 | |
commit | 8a60a36dfca344e002faad387f58b01b09cafa22 (patch) | |
tree | 59cd848efa1df225de98ab3259cb07a24ce1e3e8 | |
parent | probe-mirmon: use libcurl instead of exec wget (diff) | |
download | gentoo-mirrorstats-8a60a36dfca344e002faad387f58b01b09cafa22.tar.gz gentoo-mirrorstats-8a60a36dfca344e002faad387f58b01b09cafa22.tar.bz2 gentoo-mirrorstats-8a60a36dfca344e002faad387f58b01b09cafa22.zip |
probe-mirmon: make even less stderr
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-rwxr-xr-x | probe-mirmon | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/probe-mirmon b/probe-mirmon index 6d67fbf..1e10ef1 100755 --- a/probe-mirmon +++ b/probe-mirmon @@ -22,6 +22,7 @@ use warnings; use Date::Parse (); # dev-perl/TimeDate use File::Tempdir; # dev-perl/File-Tempdir use WWW::Curl::Easy; +use Capture::Tiny qw/capture/; sub main { my ( $timeout, $url ) = @_; @@ -84,9 +85,15 @@ sub handle_rsync { $file =~ s/\W/_/g; # translate all non-letters to _ - if ( my $fail = system '/usr/bin/rsync', qw( -q --no-motd --timeout ), $timeout, $url, "$dir/$file", '2>/dev/null' ) { + # https://stackoverflow.com/a/6331618/1583179 + my $ret; + my ($stdout, $stderr) = capture { + $ret = system '/usr/bin/rsync', qw( -q --no-motd --timeout ), $timeout, $url, "$dir/$file"; + }; + if ($ret!=0) { #warn "rsync failed, exit code $fail, $! $? $@\n"; - exit $fail; + #exit $ret; + exit 800; } open my $fh, '<', "$dir/$file" or do { |