Prints the content of a file on the server.
Command line interface
Syntax
- $ cat filename
Arguments
- filename – (file) The file to print.
Example

cat.php
- <?
- require("../plugin.php");
- if (is_ajax()) {
- if ($_POST["action"] == 'cat') {
- if (!is_file($_POST['file']) || !is_readable($_POST['file'])) die("1");
- $file = file_get_contents($_POST['file']);
- die("0".(is_utf8($file) ? $file : utf8_encode($file)));
- }
- exit;
- }
- ?>
- /**
- * Cat file
- **/
- TinyShell.plugins.cat = new Class({
- description: "Show file",
- run : function(terminal, args) {
- this.t = terminal;
- if (args.length) {
- this.file = args[0];
- this.t.ajax_request(this.print, "<?php echo $_AJAX_URL?>", "action=cat&file="+encodeURIComponent(this.file));
- } else {
- terminal.print("cat: usage: cat filename");
- terminal.resume();
- }
- },
- print: function(r) {
- if (r.substring(0, 1) != "0") this.t.print("cat: `"+this.file+"' is not a file");
- else this.t.print(r.substring(1));
- this.t.resume();
- }
- });