Changes the working directory of TinyShell and each plugin. Hint: Use TAB to autocomplete folder names.
Command line interface
Syntax
- $ cd dir
Arguments
- dir – (directory) Absolute or relative path to new working directory.
Example

cd.php
- <?
- require("../plugin.php");
- if (is_ajax()) {
- if ($_POST["action"] == 'cd') {
- if (strlen($_POST["ndir"])) {
- if (is_dir($_POST["ndir"])) {
- chdir($_POST["ndir"]);
- die("0".getcwd());
- } else die("1");
- } else {
- @chdir($_SERVER["DOCUMENT_ROOT"]);
- die("0".getcwd());
- }
- }
- exit;
- }
- ?>
- /**
- * Change directory
- **/
- TinyShell.plugins.cd = new Class({
- description: "Change directory",
- run : function(terminal, args) {
- this.t = terminal;
- this.dir = args[0] || "";
- terminal.ajax_request(this.print, "<?php echo $_AJAX_URL?>", "action=cd&ndir="+encodeURIComponent(this.dir));
- },
- print : function(r) {
- if (r.substring(0,1) == "1") this.t.print("TinyShell: cd: No such directory `"+this.dir+"'");
- else this.t.dir = r.substring(1);
- this.t.resume();
- }
- });