From: Luca Ferrari Date: Fri, 24 May 2019 12:04:41 +0000 (+0200) Subject: Fix remote paths when using SSH. X-Git-Tag: v11.0~26^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=43c1451e1dac96dac46e756406f9756bfde315ac;p=pgbadger Fix remote paths when using SSH. When specifying a directory instead of a remote file, the program aborts with a message like: % pgbadger ssh://postgres@pghost//postgres/data/log/ FATAL: can't get size of remote file, please check what's going wrong with command: ssh postgres@pghost "ls -l postgresql-Fri.log" The problem is that the set_file_list function does not include the path on the remote host, managing each file path as relative. Therefore now there is an addition of $dirs before pushing the path to the @lfiles array. However, this is due only when there is a directory, that is when the number of remote files on each function invocation is not equal at one. --- diff --git a/pgbadger b/pgbadger index be27268..e0a7e7e 100755 --- a/pgbadger +++ b/pgbadger @@ -2106,9 +2106,10 @@ sub set_file_list my($filename, $dirs, $suffix) = fileparse($file); &logmsg('DEBUG', "Looking for remote filename using command: $ssh $host_info \"ls '$dirs'$filename\""); my @rfiles = `$ssh $host_info "ls '$dirs'$filename"`; + $dirs = '' if ( @rfiles <= 1 ); foreach my $f (@rfiles) { - push(@lfiles, "ssh://$host_info/$f$fmt"); + push(@lfiles, "ssh://$host_info/$dirs$f$fmt"); } } $empty_files = 0;