Last active
June 19, 2016 03:12
-
-
Save nishidy/17ad2523687635e11281 to your computer and use it in GitHub Desktop.
Embulk plugin test.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def build_options(fields,x) | |
options = "" | |
fields.each do |field| | |
if x==0 | |
options += "-e '#{field}' " | |
else | |
options += "-e \"#{field}\" " | |
end | |
end | |
return options | |
end | |
def each_packet(path, fields, x) | |
options = build_options(fields.split(/,/),x.to_i) | |
puts options | |
io = IO.popen("tshark -E separator=, #{options} -T fields -r #{path}") | |
while line = io.gets | |
puts line | |
break | |
end | |
io.close | |
end | |
each_packet(ARGV[0],ARGV[1],ARGV[2]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment