Created
November 26, 2018 16:54
-
-
Save mcast/234972efe61f0cbe9f014978ec145fbf to your computer and use it in GitHub Desktop.
quick hack on `ilsresc --tree` to show status for all resources
This file contains hidden or 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
#!/bin/sh | |
### Copying: under GPLv3, or other by arrangement with my employer | |
### Local source: https://gitlab.internal.sanger.ac.uk/CancerIT/cgpDataOut/blob/master/bin/ilsresc-up-the-tree | |
# This is an ugly bodge, | |
# it just does what I need | |
# (iRODS 4.1.12.beta) | |
# | |
# i-cgpdev bin/ilsresc-up-the-tree | |
_main() { | |
( | |
ilsresc -l | |
echo TREE-FOLLOWS | |
ilsresc --tree --ascii | |
) | perl -e ' | |
my %res; # key=name, value=status | |
my $res; | |
while (<>) { | |
chomp; | |
last if $_ eq "TREE-FOLLOWS"; | |
next unless ($k,$v) = | |
m{^(resource name|status):\s*(.*?)\s*$}; | |
if ($k =~ /^r/) { $res = $v } else { $res{$res} = $v || "(up)" } | |
} | |
foreach (values %res) { | |
s{(down)}{\x1B[31m$1\x1B[00m}; | |
s{(up)}{\x1B[32m$1\x1B[00m}; | |
} | |
while (<>) { | |
while (my ($r, $s) = each %res) { | |
s{(^|^.*? )(\Q$r\E)(:.*?)?\s*$}{sprintf("%-50s %s\n", "$1$2$3", $s)}e; | |
} | |
print; | |
} | |
' | |
} | |
_main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ref from irods/irods#4141 (comment)