kewlhotrod

Untitled

Jul 1st, 2013
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 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.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. It outputs the contents of the file fine and executes the script. However, I get this error directly after.
  24.  
  25. node script.js
  26. #!/bin/bash
  27. NEWDIR="Test"
  28. mkdir /home/shoutcast/$NEWDIR
  29.  
  30.  
  31. /root/NodeScripts/script.js:11
  32. var result = data.replace('data', 'NEWDIR=YES');
  33. ^
  34. TypeError: Object #!/bin/bash
  35. NEWDIR="Test"
  36. mkdir /home/shoutcast/$NEWDIR
  37. has no method 'replace'
  38. at /root/NodeScripts/script.js:11:21
  39. at fs.js:266:14
  40. at Object.oncomplete (fs.js:107:15)
Advertisement
Add Comment
Please, Sign In to add comment