kewlhotrod

Untitled

Jul 1st, 2013
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 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/mkdir.sh', function (err, data) {
  8. if (err) {
  9. return console.log(err);
  10. }
  11. console.log(data.toString());
  12. var result = data.toString().replace('NEWDIR="TEST"', 'NEWDIR="' + path + '"');
  13.  
  14. fs.writeFile('/home/shoutcast/mkdir.sh', result, function (err) {
  15. if (err) return console.log(err);
  16. function puts(error, stdout, stderr) { sys.puts(stdout) }
  17. exec("bash /home/shoutcast/mkdir.sh", puts);
  18. }
  19. //Extra write to write path (whole process isn't done yet, still need to add variables and whatnot but I'm stuck on this, no matter where I place it.
  20.  
  21. fs.writeFile('/home/shoutcast/lastdir', path, function (err) {
  22. if (err) return console.log(err);
  23. });
  24.  
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment