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 sys = require('sys')
- var exec = require('child_process').exec;
- var fs = require('fs');
- fs.readFile('/home/shoutcast/lastdir', function (err, olddata) {
- if (err) {
- return console.log(err);
- }
- GLOBAL.olddir = olddata.toString()
- console.log(olddir.toString() + " Old Directory");
- console.log(path.toString() + " New Directory");
- });
- fs.readFile('/home/shoutcast/mkdir.sh', function (err, data) {
- if (err) {
- return console.log(err);
- }
- console.log(data.toString());
- var result = data.toString().replace('NEWDIR="' + olddir + '"', 'NEWDIR="' + path + '"');
- fs.writeFile('/home/shoutcast/mkdir.sh', result, function (err) {
- if (err) return console.log(err);
- function puts(error, stdout, stderr) { sys.puts(stdout) }
- exec("bash /home/shoutcast/mkdir.sh", puts);
- fs.readFile('/home/shoutcast/' + path, function (err, config){
- if (err) {
- return console.log(err);
- }
- console.log(config.toString());
- });
- });
- fs.writeFile('/home/shoutcast/lastdir', path, function (err) {
- if (err) return console.log(err);
- });
- function puts(error, stdout, stderr) { sys.puts(stdout) }
- exec("ls -la /home/shoutcast", puts);
- });
- root@fuzzyhost:~/NodeScripts# node shoutcastmkdir.js
- 49 Old Directory
- 11 New Directory
- { [Error: ENOENT, open '/home/shoutcast/11'] errno: 34, code: 'ENOENT', path: '/home/shoutcast/11' }
- total 32
- drwxr-xr-x 3 root www-data 4096 Jul 1 08:16 .
- drwxr-xr-x 5 root www-data 4096 Jun 30 21:04 ..
- -rw------- 1 root www-data 37 Jul 1 00:44 .bash_history
- -rw-r--r-- 1 root www-data 220 Jun 30 21:04 .bash_logout
- -rw-r--r-- 1 root www-data 3637 Jun 30 21:04 .bashrc
- -rw-r--r-- 1 root www-data 675 Jun 30 21:04 .profile
- drwxr-xr-x 2 root www-data 4096 Jun 30 21:05 Base
- -rw-r--r-- 1 root root 2 Jul 1 08:33 lastdir
- -rwxrwxrwx 1 root www-data 0 Jul 1 08:33 mkdir.sh
Advertisement
Add Comment
Please, Sign In to add comment