From de5cb6329b4e6a4c409d1418f16a3488a53ca953 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 27 Nov 2011 11:29:44 -0500 Subject: This is what was deployed on the lnns server --- shell/bin/cat.php | 37 ++++++++++++++++----------- shell/bin/cd.php | 18 +++++++------ shell/bin/cp.php | 72 ++++++++++++++++++++++++++++------------------------ shell/bin/editor.php | 50 ++++++++++++++++++------------------ shell/bin/grep.php | 52 +++++++++++++++++++++++++++++++++++++ shell/bin/mkdir.php | 13 ++++++++++ shell/bin/mv.php | 43 +++++++++++++++---------------- shell/bin/php.php | 9 +++++++ shell/bin/rm.php | 46 +++++++++++++++++++++++++-------- 9 files changed, 227 insertions(+), 113 deletions(-) create mode 100644 shell/bin/grep.php create mode 100644 shell/bin/mkdir.php create mode 100644 shell/bin/php.php (limited to 'shell/bin') diff --git a/shell/bin/cat.php b/shell/bin/cat.php index 8778f22..8376ca0 100644 --- a/shell/bin/cat.php +++ b/shell/bin/cat.php @@ -1,15 +1,22 @@ -'; - echo ''; - echo ''."\n"; - echo ''; - echo ''; - } - } -} - +'; + echo ''; + echo ''."\n"; + echo ''; + echo ''; + } + } +} + diff --git a/shell/bin/grep.php b/shell/bin/grep.php new file mode 100644 index 0000000..c73b911 --- /dev/null +++ b/shell/bin/grep.php @@ -0,0 +1,52 @@ + $line_contents) { + if (preg_match($pattern,$line_contents)>0) { + if ( + (self::flag($flags,'r') && !self::flag($flags,'h')) // recursive + || (self::flag($flags,'H')) // or explicit + ) { echo htmlentities($file).': '; } + if (self::flag($flags,'n')) { echo $line_number.': '; } + echo htmlentities($line_contents)."\n"; + } + } + } + + public static function main($args, $env) { + $me = array_shift($args); + $flags = ''; + while (substr($args[0],0,1) == '-') { + $flags .= array_shift($args); + } + $flags = preg_replace('/[ -]/','',$flags); + $pattern = array_shift($args); + foreach ($args as $file) { + if (self::flag($flags,'r')) { self::recurse_grep($pattern, $file, $flags); } + else { self::grep($pattern, $file, $flags); } + } + } +} diff --git a/shell/bin/mkdir.php b/shell/bin/mkdir.php new file mode 100644 index 0000000..565f47a --- /dev/null +++ b/shell/bin/mkdir.php @@ -0,0 +1,13 @@ +2) { - $dest = array_pop($args); - if (!is_dir($dest) { - echo $me.': dest must be a directory: `'.$dest."'\n"; - return 1; - } - foreach ($args as $src) { - rename($src,$dest.'/'.basename($src)); - } - } elseif (count($args)==2) { - rename($args[0],$args[1]); - } else { - echo 'Usage: '.$me." SOURCE [SOURCE2 [SOURCE3 ...]] DEST\n"; - return 1; - } - } -} - +2) { + $dest = array_pop($args); + if (!is_dir($dest)) { + echo $me.': dest must be a directory: `'.$dest."'\n"; + return 1; + } + foreach ($args as $src) { + rename($src,$dest.'/'.basename($src)); + } + } elseif (count($args)==2) { + rename($args[0],$args[1]); + } else { + echo 'Usage: '.$me." SOURCE [SOURCE2 [SOURCE3 ...]] DEST\n"; + return 1; + } + } +} diff --git a/shell/bin/php.php b/shell/bin/php.php new file mode 100644 index 0000000..0e3ba38 --- /dev/null +++ b/shell/bin/php.php @@ -0,0 +1,9 @@ +