Forum Discussion
Mike_Rodrigues
5 years agoProduct Manager
@Vitor Santos, @Mike Moniz, thanks for the discussion. I did some digging in JIRA, as this has come up before. I think I found a DataSource that solves this, it just never found its way into core. I'll get this into a sprint for review so we can see about giving it a proper release. Code looks like this:
def user = hostProps.get("win.user")
def pass = hostProps.get("win.pass")
def path = instanceProps.get("wildvalue")
def command = "cmd /c dir ${path} /a | findstr \"File(s) Dir(s)\"";
if(user && pass)
{
command = "cmd /c net use ${path} /user:${user} ${pass} & dir ${path} /a | findstr \"File(s) Dir(s)\"";
}
def stdout = (command.tokenize()).execute().text;
def result = stdout.readLines();
def fileInfo = result[-2];
def dirInfo = result[-1];
def tokens = fileInfo.split();
println("Files=${tokens[0]}");
println("UsedSpace=${tokens[2].replace(',','')}");
tokens = dirInfo.split();
println("Folders=${tokens[0]}");
println("FreeSpace=${tokens[2].replace(',','')}");
return 0;
Related Content
- 4 years ago