Create parse_netview.fish
little fish script to parse a netview output file with multiple server entries.
This commit is contained in:
37
fish_functions/parse_netview.fish
Normal file
37
fish_functions/parse_netview.fish
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
function parse_netview
|
||||||
|
echo "
|
||||||
|
@@@@@@@@@
|
||||||
|
%---------#@
|
||||||
|
%-----------+++++++++++*@
|
||||||
|
%+=::-----------------+*%
|
||||||
|
%+- .=*-:::::::-%
|
||||||
|
@%#**********-:::::::::-%
|
||||||
|
%::::::::::::::::::::::-%
|
||||||
|
%::::::::::::::::::::::-%
|
||||||
|
%::::::::::::::::::::::-%
|
||||||
|
%::::::::::::::::::::::-%
|
||||||
|
%::::::::::::::::::::::-%
|
||||||
|
%::::::::::::::::::::::-%
|
||||||
|
@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
"
|
||||||
|
if test (count $argv) -ne 2
|
||||||
|
echo Usage parse_netview /path/to/netview/output /path/to/save/parsed/data
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
set server ""
|
||||||
|
set share ""
|
||||||
|
for line in $(cat $argv[1])
|
||||||
|
if string match -q -- "*Shared resources at*" "$line"
|
||||||
|
set server $(string escape -- $(echo $line | cut -d " " -f 4 | cut -d "\\" -f 3))
|
||||||
|
end
|
||||||
|
if string match -q -- "*Disk*" "$line"
|
||||||
|
set share $(string escape -- $(echo $line | cut -d " " -f 1))
|
||||||
|
set combined "\\\\$server$share"
|
||||||
|
set cleaned (string replace -a "'" "" $combined)
|
||||||
|
set outline (string replace -a \\r \\ $cleaned)
|
||||||
|
echo -n " " \r
|
||||||
|
echo -n $outline \r
|
||||||
|
echo $outline >> $argv[2]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user