-
Notifications
You must be signed in to change notification settings - Fork 140
/
Copy pathsysenv.groovy
executable file
·54 lines (42 loc) · 1.12 KB
/
sysenv.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env -S filebot -script
log.fine '\n# Local Time #'
log.info "$now"
log.fine '\n# Process Tree #'
try {
def t = []
for (def p = ProcessHandle.current(); p != null; p = p.parent().orElse(null)) {
t.push p.info()
}
t.findResults{ p -> p.command().orElse(null) }.eachWithIndex{ p, i ->
log.info "${i == 0 ? p : ' ' * (i-1) + '└─ ' + p}"
}
} catch(Throwable e) {
log.warning "$e"
}
log.fine '\n# Environment Variables #'
_environment.toSorted{ it.key }.each{ k, v ->
log.info "$k: $v"
}
log.fine '\n# Java System Properties #'
_system.toSorted{ it.key }.each{ k, v ->
log.info "$k: $v"
}
log.fine '\n# Arguments #'
_args.argumentArray.eachWithIndex{ a, i ->
log.info "args[$i] = $a"
}
// print stat for each valid file argument as well (Unix only)
if (File.separator == '/') {
args.each{ f ->
if (f.isFile()) {
log.fine "\n# ${f} #"
['unix:dev', 'unix:ino', 'unix:nlink', 'unix:lastModifiedTime', 'unix:uid', 'unix:gid', 'unix:owner', 'unix:group', 'unix:permissions'].each{ k ->
try {
log.info "$k = ${f.getAttribute(k)}"
} catch(Throwable e) {
log.info "$k = $e"
}
}
}
}
}