I want calculate and display the free space of the home filesystem but there are 3-4 users, and all should be in javascript, how can we do ?
I know in linux shell , we can do :
df -h
But in javascript it's not
Node diskusage will do this.
Copying their example code:
#!/usr/bin/env node
var disk = require('diskusage');
// get disk usage. Takes mount point as first parameter
disk.check('/', function(err, info) {
console.log(info.free);
console.log(info.total);
});
You'll need to install node (if you don't already have it) and fetch the node-diskfree package from npm of course.
Edit: switched to a cross platform package, that runs on all OSs and doesn't scrape command line tools.
What JavaScript environment are you using? NodeJS has a childprocess module that you can use to spawn a df command, see http://nodejs.org/api/child_process.html for more details.
I imagine that you're not attempting this in a browser based JavaScript sandbox.