This commit is contained in:
BoHung Chiu 2021-12-01 20:59:18 +08:00
parent 6051cb7a40
commit 647a57b5f4
1 changed files with 22 additions and 8 deletions

View File

@ -166,22 +166,36 @@ namespace :exec_commands do
channel.send_data "#{@password}\n" channel.send_data "#{@password}\n"
else else
print "#{data}" print "#{data}"
data_str = data.to_s
if data.include?("\n") || outputs.empty? if data.include?("\n") || outputs.empty?
output_lines = data.to_s.split("\n").select{|l| l.present?} output_lines = data_str.split("\n")
outputs += output_lines first_output = nil
if outputs.count != 0
first_output = output_lines[0]
outputs[-1] += first_output
end
new_arr = output_lines[1..-1]
if data_str[-1] == "\n"
new_arr << ""
end
outputs += new_arr
if update if update
update_thread_infos_for_exec(output_lines,false,true) if @flag if first_output
update_infos_for_exec(output_lines,false,true) update_thread_infos_for_exec(first_output,true) if @flag
update_infos_for_exec(first_output,true)
end
update_thread_infos_for_exec(new_arr,false,true) if @flag
update_infos_for_exec(new_arr,false,true)
end end
else else
if outputs.count == 0 if outputs.count == 0
outputs.push(data.to_s) outputs.push(data_str)
else else
outputs[-1] += (data.to_s rescue "") outputs[-1] += (data_str rescue "")
end end
if update if update
update_thread_infos_for_exec(data,true) if @flag update_thread_infos_for_exec(data_str,true) if @flag
update_infos_for_exec(data,true) update_infos_for_exec(data_str,true)
end end
end end
end end