Created
November 23, 2016 14:00
-
-
Save theeye-io/5327b2cf1a955890dce44b574287f1e0 to your computer and use it in GitHub Desktop.
WIN_checkDirectoryFreeSpace.js
This file contains 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
var exec = require('child_process').exec; | |
var dir = process.argv[2]; | |
var limit = process.argv[3]; | |
var cmd = 'powershell -noprofile -command "(ls -r ' + dir + ' |measure -s Length).Sum"'; | |
exec(cmd,function(err,stdout,stderr){ | |
if(err){ | |
console.log(err); | |
console.log(stderr); | |
return console.log('failure'); | |
} | |
var total = parseInt(stdout); | |
console.log('total occupied ' + total + ' , limit is ' + limit); | |
var state = (total>limit) ? 'failure':'success'; | |
console.log(state); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment