Untermenü

TYPO3 Chat hosted by kj187kj.

Join now


Chat about what's on your mind. More about public chats.

Sunsite SourceForge.net

Statistik
Tutorials Gesamt:
56
Tutorials Hidden:
1
Kommentare:
499

Bücher zum Thema

Links / Friends
» typo3.org
» T3N Magazin
» CSS Tutorials
» TYPO3 SEO
» TYPO3 Blog



 

CLI (Shell) Scripte


Tutorial abonnieren:
Author:
Julian Kleinhans
Author E-Mail:
Eingetragen:
11.02.2007 - 21:59

Quelle:
Keine Quelle vorhanden
Klicks:
976





CLI steht für Command line interface. CLI Scripte werden benutzt um bestimmte Abläufe zu automatisieren. Sie werden meist über CronJobs angestossen.

Es werden zwei Dateien benötigt. Eine conf Datei und eine für das eigentliche Script.

conf.php
0:   <?php
// DO NOT REMOVE OR CHANGE THESE 3 LINES:
define('TYPO3_MOD_PATH''../typo3conf/ext/MYEXTKEY/cli/');
$BACK_PATH '../../../../typo3/';
$MCONF['name'] = '_CLI_beuser';
?>
1:  
2:  
3:  
4:  
5:  
Hier koennen Sie sich den Quellcode kopieren.

Wichtig ist hier der Pfad zum Ordner wo das Script liegt. In diesem Fall liegt es unter typo3conf/ext/MYEXTKEY/cli/. Desweiteren MUSS ein Backenduser angelegt werden der in unserem Fall _CLI_beuser_ heisst. Er muss kein Admin bekommen. Wichtig ist nur das er existiert. Mehr brauch in der conf Datei auch nicht angepasst werden.

cli.myscript.php
Vor dem öffnenden PHP Tag sollte folgende Zeile stehen

#! /usr/bin/php



0:   <?php

// *****************************************
// Standard initialization of a CLI module:
// *****************************************

// 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!
define('PATH_thisScript',$_ENV['_']?$_ENV['_']:$_SERVER['_']);

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

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


# HERE you run your application!
?>
1:  
2:  
3:  
4:  
5:  
6:  
7:  
8:  
9:  
10:  
11:  
12:  
13:  
14:  
15:  
16:  
17:  
18:  
19:  
20:  
21:  
Hier koennen Sie sich den Quellcode kopieren.

Der obere Teil ist für die Initialisierung zuständig und ist vom Aufbau her immer gleich. Ab dem Part # HERE you run your application! könnt Ihr euch austoben :-)

Viel spass.. wenn es Probleme gibt, einfach hier posten...


Update: Für TYPO3 4.1 und höher gibt es ein neues Command Line Interface. Ein Tutorial findet Ihr hier http://www.typo3-tutorials.org/tutorials/entwicklung/cli-das-neue-command-line-interface.html





Ergebnis: Kein Ergebnis vorhanden



Zum Eingabeformular

 
Julian Kleinhans 07.07.2008 22:29 Uhr 

Hi Michiel,

thanks for your note... i have post a new tutorial for the new command line interface
you can find it here: http://www.typo3-tutorials.org/tutorials/entwicklung/cli-das-neue-command-line-interface.html

but only in german ;)

cheers
julian
 
 
 
Jörg Sprung 16.04.2007 21:54 Uhr 

If you want running CLI, please run it with full path not only relative.

e.g. /var/www/typo3conf/ext/EXTKEY/cli/cli.CLISCRIPTNAME.php
 
 
 
Michiel Roos 27.02.2007 15:33 Uhr 

Please note,

This tutorial will only work if you are building cli scripts for 4.0.x.

Not for 4.1.*

I'll see if I can do a small tut on the wiki to explain. Or find the proper docs for developing cli scripts for 4.1.*

Cheers,


Michiel Roos
 
 
 
Seite: 1