Cd

Changes the working directory of TinyShell and each plugin. Hint: Use TAB to autocomplete folder names.

Command line interface

Syntax

  1. $ cd dir

Arguments

  • dir – (directory) Absolute or relative path to new working directory.

Example

cd.php

  1. <?
  2. require("../plugin.php");
  3. if (is_ajax()) {
  4. if ($_POST["action"] == 'cd') {
  5. if (strlen($_POST["ndir"])) {
  6. if (is_dir($_POST["ndir"])) {
  7. chdir($_POST["ndir"]);
  8. die("0".getcwd());
  9. } else die("1");
  10. } else {
  11. @chdir($_SERVER["DOCUMENT_ROOT"]);
  12. die("0".getcwd());
  13. }
  14. }
  15. exit;
  16. }
  17. ?>
  18. /**
  19. * Change directory
  20. **/
  21. TinyShell.plugins.cd = new Class({
  22. description: "Change directory",
  23. run : function(terminal, args) {
  24. this.t = terminal;
  25. this.dir = args[0] || "";
  26. terminal.ajax_request(this.print, "<?php echo $_AJAX_URL?>", "action=cd&ndir="+encodeURIComponent(this.dir));
  27. },
  28. print : function(r) {
  29. if (r.substring(0,1) == "1") this.t.print("TinyShell: cd: No such directory `"+this.dir+"'");
  30. else this.t.dir = r.substring(1);
  31. this.t.resume();
  32. }
  33. });

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>