[TYPO3-UG Bremen] CLI Funktion über ssh nutzen?

Jens Stangenberg jens at stngnbrg.de
Mon Feb 4 11:33:55 CET 2008


Vorbemerkung: Diese Mail hatte ich schon am 11.1. direkt nach unserem 
Treffen abgeschickt. Weil aber wohl ein (zu großer?) Anhang dran war, 
ist sie nie angekommen - wie mir scheint. Das habe ich erst später 
bemerkt. Sollte sie doch angekommen sein... sorry für die Doppelung. 
Jetzt also. Die große Datei findet ihr nun als Downloadlink auf unserer 
Website.
    Vielleicht können wir bei unserem nächsten Treffen kurz mal drüber 
reden. Wäre mir eine Hilfe.
Bis dann.

Moin an alle Bremen TYPO3ler,
    wir hatten beim letzten UserTreffen auch über die CLI Funktion 
gesprochen, um die Datenbankintegrität bei zu geringem memory-limit über 
ssh zu prüfen und per cronjob automatisch zu aktualisieren.
    Als Downloadlink findet ihr den Artikel von Jochen Weiland aus der 
letzten T3N. Bei diesem Teil geht es um die Überschrift 
"Wartungsarbeiten durchführen" auf Seite 3. (Habe euch den gesamten 
Artikel eingescannt, falls es interessiert)
    http://www.zellgemeinde-bremen.de/typo3_backend_tipps.pdf
   
Ich habe wie angegeben
einen Backenduser mit _cli_lowlevel angelegt.
Erklärungstextdatei ist: HOWTO_clean... im Verzeichnis lowlevel

dann die Zeile
#!/usr/bin/php -q   auf
#!/usr/local/bin/php -q  geändert. (Weil das beim Hosting so nötig ist)

Dann über ssh auf den typo3-Ordner gewechselt und folgenden Befehl 
eingegeben
 ./cli_dispatch.phpsh lowlevel_cleaner

Folgendes Ergebnis kommt raus:
Die rote Zeile kann ich leider nicht deuten. Hat jemand einen Tipp für mich?
Hier hakt es bei mir (Die aktuelle cli_dispatch.phpsh - Datei habe ich 
auch mal angehängt).

(12:21:06) [typo3] ./cli_dispatch.phpsh lowlevel_cleaner
Error in argument 1, char 3: option not found
Usage: php [-q] [-h] [-s] [-v] [-i] [-f <file>]
       php <file> [args...]
  -a               Run interactively
  -C               Do not chdir to the script's directory
  -c <path>|<file> Look for php.ini file in this directory
  -n               No php.ini file will be used
  -d foo[=bar]     Define INI entry foo with value 'bar'
  -e               Generate extended information for debugger/profiler
  -f <file>        Parse <file>.  Implies `-q'
  -h               This help
  -i               PHP information
  -l               Syntax check only (lint)
  -m               Show compiled in modules
  -q               Quiet-mode.  Suppress HTTP Header output.
  -s               Display colour syntax highlighted source.
  -v               Version number
  -w               Display source with stripped comments and whitespace.
  -z <file>        Load Zend extension <file>.
(12:22:28) [typo3]

Es gibt auch einen Kommentar bei Mittwald, der mir nicht wirklich 
weiterhilft
http://www.typo3.net/forum/list/list_post//54562/

Lieben Gruß und einen schönes Wochenstart
Jens

------------------------------------------------------------------------

#! /usr/local/bin/php -q
<?php

// *****************************************
// CLI module dispatcher.
// This script can take a "cliKey" as first argument and uses that to look up the path of the script to include in the end.
// See configuration of this feature in $TYPO3_CONF_VARS['SC_OPTIONS']['GLOBAL']['cliKeys']
// The point is to have only ONE script dealing with the environment initialization while the actual processing is all a developer should care for.
// *****************************************

if (PHP_SAPI!='cli')    {
    	die('ERROR: Not called from a command line interface (eg. a shell or scheduler).'.chr(10));
}

	// Defining circumstances for CLI mode:
define('TYPO3_cliMode', TRUE);

	// Defining PATH_thisScript here: Must be the ABSOLUTE path of this script in the right context:
	// This will work as long as the script is called by it's absolute path!
$temp_PATH_thisScript = isset($_SERVER['argv'][0]) ? $_SERVER['argv'][0] : (isset($_ENV['_']) ? $_ENV['_'] : $_SERVER['_']);

	// Alternatively, in some environments, we might be able to figure out the absolute path (with no "../" and "./" in) from environment variables...
if ($temp_PATH_thisScript{0}!='/')	{
	$temp_CURRENT_DIR = $_SERVER['PWD'].'/';
	$temp_PATH_thisScript = $temp_CURRENT_DIR.ereg_replace('\.\/','',$temp_PATH_thisScript);
	if (!@is_file($temp_PATH_thisScript))	{
		die(wordwrap('ERROR: '.$temp_PATH_thisScript.' was not a file. Maybe your environment does not support running this script with a relative path? Try to run the script with its absolute path and you should be fine.'.chr(10).chr(10)));
	}
}
define('PATH_thisScript',$temp_PATH_thisScript);

	// First argument is a key that points to the script configuration
define('TYPO3_cliKey', $_SERVER['argv'][1]);

	// Include init file:
require(dirname(PATH_thisScript).'/init.php');

if (defined('TYPO3_cliInclude'))	{
	include(TYPO3_cliInclude);
} else {
	echo 'ERROR: Nothing to include.'.chr(10);
	exit;
}
?>



More information about the TYPO3-UG-bremen mailing list