[Typo3] TYPO3_cliMode initializing typo3 in a php shell errors
Simon Tuck
e-mailNO at SPAMeyejet.com
Sat May 7 16:58:54 CEST 2005
Christoph Köpernick @ atkon wrote:
> dear list,
>
> i´m trying to initialize the typo3 backend in an php shell script. I
> followed the guidelines described in "inside typo3", but some problems
> occur:
>
> 1. $HTTP_ENV_VARS["_"]
>
> it seems impossible for me to get the script path by this statement. I
> tested this on debian and red hat systems. First of all i can´t call the
> element by it´s name ("_"), but by it´s number. And the value is:
> /usr/bin/php so that doesn´t help me. So i set the path manually, that
> works. Do you know if this problem depends on the OS or my
> configuration? But now i can use the conf.php file ;)
I have no idea what $HTTP_ENV_VARS["_"] is supposed to mean either, I have
never found any reference to this value as a valid server variable and i
don't think it is meant to be, it just *looks* like some kind of server
variable:
http://typo3.org/documentation/document-library/maillisttofaq/Transfer_from_the_ma/
At any rate for your script to work you need to define it:
$HTTP_ENV_VARS["_"]="path/to/my/script.php";
then $dir = dirname($HTTP_ENV_VARS["_"]); will be OK.
>
> 2. init.php
>
> i call init.php by require('/home/www/htdocs/typo3/typo3/init.php');
> because also the relative $BACK_PATH = '../../../../typo3/'; doesn´t
> work. But now i get the following message:
>
> Error in init.php: Path to TYPO3 main dir could not be resolved
> correctly. <br /><br />
> This happens if the last 6 characters of this path,
> /home/www/htdocs/typo3/typo3conf/ext/atkon_searchagent/, (\$temp_path)
> is NOT "typo3/" for some reason. <br />
> You may have a strange server configuration.
> Or maybe you didn't set constant TYPO3_MOD_PATH in your
> module?<br /><strong>If you expect any help from anybody on this issue,
> you should save this page as an html document and send it along with
> your request for help!</strong><HR><pre>Array
> (
> [TYPO3_OS] =>
> [PATH_thisScript] =>
> /home/www/htdocs/typo3/typo3conf/ext/atkon_searchagent/cronmod
> [php_sapi_name()] => cli
> [TYPO3_MOD_PATH] => ../typo3conf/ext/atkon_searchagent/cronmod/
> [PATH_TRANSLATED] =>
> /home/www/htdocs/typo3/typo3conf/ext/atkon_searchagent/cronmod/index.phpsh
> [SCRIPT_FILENAME] =>
> /home/www/htdocs/typo3/typo3conf/ext/atkon_searchagent/cronmod/index.phpsh
> )
>
> ... phpinfo()
>
>
> So something with the script path isn´t right yet. Can please anyone
> make some suggestions how to solve this/had the same problem and found a
> solution?
If you are trying to set up the dmailercron script then all you should need
to do is set $HTTP_ENV_VARS["_"] correctly. if, however, you are setting up
your own cron script in an extension then i can give you the code that
worked for me:
// Defining Client mode
define('TYPO3_cliMode', TRUE);
// The path of this script relative to the BE
// Assumes local installation!! (otherwise use
// a conf file - for further details check:
// http://typo3.org/documentation/document-library/doc_core_inside/conf_php-1/
define('TYPO3_MOD_PATH', '../directory/of/my/script/');
// The relative path back to the BE from this script
$BACK_PATH='../../../../typo3/';
// The username initialized in init.php for this session
// must be prefixed with '_CLI_' and must be a real BE-user!
$MCONF['name'] = '_CLI_blabla';
// 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','/absolute/path/to/the/script.php');
// Include init file:
if (file_exists(dirname(PATH_thisScript).'/'.$BACK_PATH.'init.php')) {
require(dirname(PATH_thisScript).'/'.$BACK_PATH.'init.php');
} else {
die('not found: '.dirname(PATH_thisScript).'/'.$BACK_PATH.'init.php');
}
--> at this point you should have a valid TYPO3 BE session...
>
> Searching the archive and looking into EXT: direct_mail shows me that
> it´s very rarely to use this typo3 feature. In direct_mail the init.php
> isn´t used. Maybe because it´s not possible?
>
> thanks for comments,
> christoph köpernick
>
>
>
More information about the TYPO3-english
mailing list