kewlhotrod

Working Node.js Directory Creator

Jul 1st, 2013
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. var sys = require('sys');
  2. var exec = require('child_process').exec;
  3. var path = Math.floor(Math.random()*101);
  4.  
  5. var fs = require('fs');
  6.  
  7. fs.readFile('/home/shoutcast/lastdir', function (err, olddata) {
  8. if (err) {
  9. return console.log(err);
  10. }
  11. console.log(olddata.toString());
  12. GLOBAL.olddir = olddata.toString()
  13. console.log(olddir.toString());
  14.  
  15. });
  16.  
  17. fs.readFile('/home/shoutcast/mkdir.sh', function (err, data) {
  18. if (err) {
  19. return console.log(err);
  20. }
  21. console.log(data.toString());
  22. var result = data.toString().replace('NEWDIR="' + olddir + '"', 'NEWDIR="' + path + '"');
  23.  
  24. fs.writeFile('/home/shoutcast/mkdir.sh', result, function (err) {
  25. if (err) return console.log(err);
  26. function puts(error, stdout, stderr) { sys.puts(stdout) }
  27. exec("bash /home/shoutcast/mkdir.sh", puts);
  28. });
  29.  
  30.  
  31.  
  32. fs.writeFile('/home/shoutcast/lastdir', path, function (err) {
  33. if (err) return console.log(err);
  34. });
  35.  
  36.  
  37. });
Advertisement
Add Comment
Please, Sign In to add comment