kewlhotrod

Untitled

Jul 1st, 2013
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 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. fs.readFile('/home/shoutcast/mkdir.sh', function (err, data) {
  7. if (err) {
  8. return console.log(err);
  9. }
  10. console.log(data.toString('utf8'));
  11. var result = data.toString().replace('data', 'NEWDIR=YES');
  12.  
  13. fs.writeFile(data, result, 'utf8', function (err) {
  14. if (err) return console.log(err);
  15. });
  16. });
  17.  
  18. function puts(error, stdout, stderr) { sys.puts(stdout) }
  19. exec("bash /home/shoutcast/mkdir.sh", puts);
  20.  
  21.  
  22.  
  23.  
  24.  
  25. node script.js
  26. #!/bin/bash
  27. NEWDIR="Test"
  28. mkdir /home/shoutcast/$NEWDIR
  29.  
  30.  
  31. fs.js:418
  32. binding.open(pathModule._makeLong(path),
  33. ^
  34. TypeError: path must be a string
  35. at Object.fs.open (fs.js:418:11)
  36. at Object.fs.writeFile (fs.js:942:6)
  37. at /root/NodeScripts/script.js:13:6
  38. at fs.js:266:14
  39. at Object.oncomplete (fs.js:107:15)
  40. root@fuzzyhost:~/NodeScripts#
Advertisement
Add Comment
Please, Sign In to add comment