Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var sys = require('sys');
- var exec = require('child_process').exec;
- var path = Math.floor(Math.random()*101);
- var fs = require('fs');
- fs.readFile('/home/shoutcast/mkdir.sh', function (err, data) {
- if (err) {
- return console.log(err);
- }
- console.log(data.toString('utf8'));
- var result = data.replace('data', 'NEWDIR=YES');
- fs.writeFile(data, result, 'utf8', function (err) {
- if (err) return console.log(err);
- });
- });
- function puts(error, stdout, stderr) { sys.puts(stdout) }
- exec("bash /home/shoutcast/mkdir.sh", puts);
- It outputs the contents of the file fine and executes the script. However, I get this error directly after.
- node script.js
- #!/bin/bash
- NEWDIR="Test"
- mkdir /home/shoutcast/$NEWDIR
- /root/NodeScripts/script.js:11
- var result = data.replace('data', 'NEWDIR=YES');
- ^
- TypeError: Object #!/bin/bash
- NEWDIR="Test"
- mkdir /home/shoutcast/$NEWDIR
- has no method 'replace'
- at /root/NodeScripts/script.js:11:21
- at fs.js:266:14
- at Object.oncomplete (fs.js:107:15)
Advertisement
Add Comment
Please, Sign In to add comment