Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Turris
ucollect
Commits
b5d0fab0
Verified
Commit
b5d0fab0
authored
Dec 16, 2016
by
Michal 'vorner' Vaner
Browse files
Experiment: Get the IP prefix to sort them out
parent
f5807f1a
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/master/amihacked/process/Cargo.toml
View file @
b5d0fab0
...
...
@@ -5,3 +5,4 @@ authors = ["Michal 'vorner' Vaner <michal.vaner@nic.cz>"]
[dependencies]
csv
=
"0.14"
regex
=
"0.1"
src/master/amihacked/process/src/main.rs
View file @
b5d0fab0
extern
crate
csv
;
extern
crate
regex
;
use
std
::
process
::
*
;
use
std
::
thread
;
use
std
::
sync
::
*
;
use
regex
::
Regex
;
fn
main
()
{
let
mut
running
=
Vec
::
new
();
for
arg
in
std
::
env
::
args
()
{
let
a_cp
=
arg
.clone
();
let
prefix
=
Regex
::
new
(
r"^(.[^.]?)"
)
.unwrap
();
running
.push
(
thread
::
spawn
(
move
||
{
let
mut
unzip
=
Command
::
new
(
"pbzip2"
)
.arg
(
"-dc"
)
.arg
(
a_cp
)
.stdout
(
Stdio
::
piped
())
.spawn
()
.expect
(
"Failed to start unzip"
);
{
...
...
@@ -14,7 +18,9 @@ fn main() {
let
mut
reader
=
csv
::
Reader
::
from_reader
(
&
mut
output
);
for
row
in
reader
.records
()
{
println!
(
"{:?}"
,
row
);
let
row
=
row
.unwrap
();
let
iprefix
=
prefix
.captures
(
&
row
[
0
])
.expect
(
"Doesn't match"
)
.at
(
1
)
.unwrap
();
println!
(
"{} {}"
,
&
row
[
0
],
iprefix
);
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment