kewlhotrod

Untitled

Jul 1st, 2013
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 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. var sys = require('sys')
  5. var exec = require('child_process').exec;
  6.  
  7. var fs = require('fs');
  8.  
  9. fs.readFile('/home/shoutcast/lastdir', function (err, olddata) {
  10. if (err) {
  11. return console.log(err);
  12. }
  13. GLOBAL.olddir = olddata.toString()
  14. console.log(olddir.toString() + " Old Directory");
  15. console.log(path.toString() + " New Directory");
  16.  
  17. });
  18.  
  19. fs.readFile('/home/shoutcast/mkdir.sh', function (err, data) {
  20. if (err) {
  21. return console.log(err);
  22. }
  23. console.log(data.toString());
  24. var result = data.toString().replace('NEWDIR="' + olddir + '"', 'NEWDIR="' + path + '"');
  25.  
  26. fs.writeFile('/home/shoutcast/mkdir.sh', result, function (err) {
  27. if (err) return console.log(err);
  28. function puts(error, stdout, stderr) { sys.puts(stdout) }
  29. exec("bash /home/shoutcast/mkdir.sh", puts);
  30.  
  31. fs.readFile('/home/shoutcast/' + path, function (err, config){
  32. if (err) {
  33. return console.log(err);
  34. }
  35. console.log(config.toString());
  36. });
  37. });
  38.  
  39.  
  40.  
  41. fs.writeFile('/home/shoutcast/lastdir', path, function (err) {
  42. if (err) return console.log(err);
  43. });
  44.  
  45. function puts(error, stdout, stderr) { sys.puts(stdout) }
  46. exec("ls -la /home/shoutcast", puts);
  47.  
  48.  
  49. });
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58. root@fuzzyhost:~/NodeScripts# node shoutcastmkdir.js
  59. 49 Old Directory
  60. 11 New Directory
  61.  
  62. { [Error: ENOENT, open '/home/shoutcast/11'] errno: 34, code: 'ENOENT', path: '/home/shoutcast/11' }
  63. total 32
  64. drwxr-xr-x 3 root www-data 4096 Jul 1 08:16 .
  65. drwxr-xr-x 5 root www-data 4096 Jun 30 21:04 ..
  66. -rw------- 1 root www-data 37 Jul 1 00:44 .bash_history
  67. -rw-r--r-- 1 root www-data 220 Jun 30 21:04 .bash_logout
  68. -rw-r--r-- 1 root www-data 3637 Jun 30 21:04 .bashrc
  69. -rw-r--r-- 1 root www-data 675 Jun 30 21:04 .profile
  70. drwxr-xr-x 2 root www-data 4096 Jun 30 21:05 Base
  71. -rw-r--r-- 1 root root 2 Jul 1 08:33 lastdir
  72. -rwxrwxrwx 1 root www-data 0 Jul 1 08:33 mkdir.sh
Advertisement
Add Comment
Please, Sign In to add comment