module VirusScanService
  class KasperskyRunner
    class LinuxExecutor
      # not tested on real production as I'm using windows VM for virus scans
      def scan(file_path, log_path)
        system 'sudo',
          '/opt/kaspersky/kes4lwks/bin/kes4lwks-control',
          '--scan-file',
          file_path.to_s,
          ">>",
          log_path.to_s
      end
    end
  end
end

require 'open3'
module VirusScanService
  class KasperskyRunner
    class LinuxExecutor
      def scan(file_path, log_path)
	stdout, stderr, status = Open3.capture3(
         "sudo /opt/kaspersky/kes4lwks/bin/kes4lwks-control --scan-file #{file_path.to_s}"
        )
        File.open(log_path.to_s, 'w') { |file| file.write(stdout) }
      end
    end
  end
end

Fix linux executer -- output redirection to file
Fix linux executer -- output redirection to file

Use Open3 instead of a system call.
This was not working, as it interpreted ">>" as a command line argument,
not an output redirection
