HowTo: Running a cronscript using TYPO3 with CLI

View: New views
20 Messages — Rating Filter:   Alert me  
< Prev | 1 - 2 | Next >

HowTo: Running a cronscript using TYPO3 with CLI

by Steffen Kamper-2 :: Rate this Message:

| View Threaded | Show Only this Message

Hi,

i searched for detailed information how to setup a CLI cronjob, but i only
found uncomplete infos or unanswered questions, so here comes a short
description how to do it.

1) install extension "lowlevel" (sysextension)
2) create a BE-User _cli_cronjob (doesn't need any rights, just create)
3) in your extension create folder cli
4) in folder cli create 2 files: conf.php, cronjob.phpsh
5) edit conf.php and insert:
<?php
// DO NOT REMOVE OR CHANGE THESE 3 LINES:
define('TYPO3_MOD_PATH', '../typo3conf/ext/yourextension/cli/');
$BACK_PATH = '../../../../typo3/';
$MCONF['name'] = '_CLI_cronjob'; //use name of your BE-User
?>

6) edit cronjob.phpsh and insert:
#! /usr/bin/php -q
<?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!

that's it. You can test the script at the console, remember to call it with
absolute path:
/var/www/.../typo3conf/ext/yourextension/cli/cronjob.phpsh

very useful is to add output of the script to a logfile, e.g.
/var/www/.../typo3conf/ext/yourextension/cli/cronjob.phpsh >>
/var/www/.../fileadmin/logs/cronjob.log

happy CLI ;-)

vg  Steffen


_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: HowTo: Running a cronscript using TYPO3 with CLI

by Steffen Kamper-2 :: Rate this Message:

| View Threaded | Show Only this Message

some additional:

it's useful to use command line parameters to allow multiple actions in your
script.
Use $_SERVER["argv"] to examine these command line parameters.

Some jobs are still done in the lowlevel extension, it's really helpful to
read the file "HOWTO_clean_up_TYPO3_installations.txt" inside the extension.

vg  Steffen


_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: HowTo: Running a cronscript using TYPO3 with CLI

by Martin Kutschker-3 :: Rate this Message:

| View Threaded | Show Only this Message

Steffen Kamper schrieb:
> Hi,
>
> i searched for detailed information how to setup a CLI cronjob, but i only
> found uncomplete infos or unanswered questions, so here comes a short
> description how to do it.

Please don't do it this way. Use the script typo3/cli_dispatch.php to
launch your script.

Masi
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: HowTo: Running a cronscript using TYPO3 with CLI

by Steffen Kamper-2 :: Rate this Message:

| View Threaded | Show Only this Message


"Martin Kutschker" <martin.kutschker-n0spam@...> schrieb im
Newsbeitrag
news:mailman.1.1199370737.23915.typo3-dev@......

> Steffen Kamper schrieb:
>> Hi,
>>
>> i searched for detailed information how to setup a CLI cronjob, but i
>> only found uncomplete infos or unanswered questions, so here comes a
>> short description how to do it.
>
> Please don't do it this way. Use the script typo3/cli_dispatch.php to
> launch your script.
>
> Masi

Hi,

what is the disadvantage of this way? Looking to cli_dispatch it does nearly
the same, and i did successfully running cronjobs my way (it's also same as
indexed_search does)

vg  Steffen


_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: HowTo: Running a cronscript using TYPO3 with CLI

by Ernesto Baschny [cron IT] :: Rate this Message:

| View Threaded | Show Only this Message

Martin Kutschker wrote: on 03.01.2008 15:32:

>> i searched for detailed information how to setup a CLI cronjob, but i
>> only found uncomplete infos or unanswered questions, so here comes a
>> short description how to do it.
>
> Please don't do it this way. Use the script typo3/cli_dispatch.php to
> launch your script.

"Inside TYPO3" describes the old-school way Steffen describes. It looks
pretty "complete" to me:

http://typo3.org/documentation/document-library/core-documentation/doc_core_inside/4.1.0/view/3/5/#id3561750

but unfortunately this is "old-school". As Masi said, using
typo3/cli_dispatch.php is the "way to go". Someone has to change that
section in "Inside TYPO3" to reflect that, as I don't see cli_dispatch
documented anywhere.

You can follow the examples in the sysext/lowlevel. Basically this means:

=> BE-user "_CLI_lowlevel". This user has to have the rights you need
the script to have. So if the script performs high-level TCEmain
operations, it needs to have access to the fields you want to change!

=> ext_localconf.php:
$TYPO3_CONF_VARS['SC_OPTIONS']['GLOBAL']['cliKeys']['lowlevel_cleaner']
= array('EXT:lowlevel/dbint/cli/cleaner_cli.php','_CLI_lowlevel');

=> lowlevel/dbint/cli/cleaner_cli.php:
Straight PHP-code where you already have the TYPO3-framework loaded (no
more BACK_PATH stuff etc). Just "do your stuff" here.


Then call your stuff with:
$ php <Root>/typo3/cli_dispatch.phpsh lowlevel_cleaner


Cheers,
Ernesto
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: HowTo: Running a cronscript using TYPO3 with CLI

by Ernesto Baschny [cron IT] :: Rate this Message:

| View Threaded | Show Only this Message

Steffen Kamper wrote: on 03.01.2008 16:30:

> "Martin Kutschker" <martin.kutschker-n0spam@...> schrieb im
> Newsbeitrag
> news:mailman.1.1199370737.23915.typo3-dev@......
>> Steffen Kamper schrieb:
>>> Hi,
>>>
>>> i searched for detailed information how to setup a CLI cronjob, but i
>>> only found uncomplete infos or unanswered questions, so here comes a
>>> short description how to do it.
>> Please don't do it this way. Use the script typo3/cli_dispatch.php to
>> launch your script.
>>
>> Masi
>
> Hi,
>
> what is the disadvantage of this way? Looking to cli_dispatch it does nearly
> the same, and i did successfully running cronjobs my way (it's also same as
> indexed_search does)

The advantage is that your module won't need to fiddle with BACK_PATH,
bizarre relative "../../.." that most people don't understand, bizarre
techniques for getting the absolute path of your cli
(define('PATH_thisScript',$_ENV['_']?$_ENV['_']:$_SERVER['_']);), etc.
This is all done via cli_dispatch already, and you can concentrate on
your task (the functionality of your CLI).

Also think that sometime cli_dispatch might be implemented differently,
or there might be other interfaces to your CLIs. Using the API is the
only way to ensure that "your cli" will conform in future.

Cheers,
Ernesto
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: HowTo: Running a cronscript using TYPO3 with CLI

by Steffen Kamper-2 :: Rate this Message:

| View Threaded | Show Only this Message


"Ernesto Baschny [cron IT]" <ernst@...> schrieb im Newsbeitrag
news:mailman.1.1199374308.6833.typo3-dev@......

> Martin Kutschker wrote: on 03.01.2008 15:32:
>
>>> i searched for detailed information how to setup a CLI cronjob, but i
>>> only found uncomplete infos or unanswered questions, so here comes a
>>> short description how to do it.
>>
>> Please don't do it this way. Use the script typo3/cli_dispatch.php to
>> launch your script.
>
> "Inside TYPO3" describes the old-school way Steffen describes. It looks
> pretty "complete" to me:
>
> http://typo3.org/documentation/document-library/core-documentation/doc_core_inside/4.1.0/view/3/5/#id3561750
>
> but unfortunately this is "old-school". As Masi said, using
> typo3/cli_dispatch.php is the "way to go". Someone has to change that
> section in "Inside TYPO3" to reflect that, as I don't see cli_dispatch
> documented anywhere.
>
> You can follow the examples in the sysext/lowlevel. Basically this means:
>
> => BE-user "_CLI_lowlevel". This user has to have the rights you need
> the script to have. So if the script performs high-level TCEmain
> operations, it needs to have access to the fields you want to change!
>
> => ext_localconf.php:
> $TYPO3_CONF_VARS['SC_OPTIONS']['GLOBAL']['cliKeys']['lowlevel_cleaner']
> = array('EXT:lowlevel/dbint/cli/cleaner_cli.php','_CLI_lowlevel');
>
> => lowlevel/dbint/cli/cleaner_cli.php:
> Straight PHP-code where you already have the TYPO3-framework loaded (no
> more BACK_PATH stuff etc). Just "do your stuff" here.
>
>
> Then call your stuff with:
> $ php <Root>/typo3/cli_dispatch.phpsh lowlevel_cleaner
>
>
> Cheers,
> Ernesto

Hi Ernesto,

i didn't found this document, thx for the link.
I don't see a BACK_PATH problem, it's same stuff as in every BE-module -
defined one time and could be used.
I didn't used it, as there is also the way with the constants or
EXT:xxx-syntax.

Ok, switching to cli_dispatch is no problem, only missing documentation. But
all is done in lowlevel, so these parts could be copied.
So little additional question, how can I access commandline parameters? e.g.
i want to start my script this way
/abspath/typo3/cli_dispatch.phpsh mysscript -f 100

vg  Steffen


_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: HowTo: Running a cronscript using TYPO3 with CLI

by Ernesto Baschny [cron IT] :: Rate this Message:

| View Threaded | Show Only this Message

Steffen Kamper wrote: on 03.01.2008 16:54:

>>>> i searched for detailed information how to setup a CLI cronjob, but i
>>>> only found uncomplete infos or unanswered questions, so here comes a
>>>> short description how to do it.
>>> Please don't do it this way. Use the script typo3/cli_dispatch.php to
>>> launch your script.
>> "Inside TYPO3" describes the old-school way Steffen describes. It looks
>> pretty "complete" to me:
>>
>> http://typo3.org/documentation/document-library/core-documentation/doc_core_inside/4.1.0/view/3/5/#id3561750
>>
>> but unfortunately this is "old-school". As Masi said, using
>> typo3/cli_dispatch.php is the "way to go". Someone has to change that
>> section in "Inside TYPO3" to reflect that, as I don't see cli_dispatch
>> documented anywhere.
>>
>> You can follow the examples in the sysext/lowlevel. Basically this means:
>>
>> => BE-user "_CLI_lowlevel". This user has to have the rights you need
>> the script to have. So if the script performs high-level TCEmain
>> operations, it needs to have access to the fields you want to change!
>>
>> => ext_localconf.php:
>> $TYPO3_CONF_VARS['SC_OPTIONS']['GLOBAL']['cliKeys']['lowlevel_cleaner']
>> = array('EXT:lowlevel/dbint/cli/cleaner_cli.php','_CLI_lowlevel');
>>
>> => lowlevel/dbint/cli/cleaner_cli.php:
>> Straight PHP-code where you already have the TYPO3-framework loaded (no
>> more BACK_PATH stuff etc). Just "do your stuff" here.
>>
>>
>> Then call your stuff with:
>> $ php <Root>/typo3/cli_dispatch.phpsh lowlevel_cleaner

> Hi Ernesto,
>
> i didn't found this document, thx for the link.
> I don't see a BACK_PATH problem, it's same stuff as in every BE-module -
> defined one time and could be used.

The same problem you have with BE-modules will arise in CLI-modules. See
thread "SymLinked typo3/ext" about some trouble this hardcoded path
might produce.

> I didn't used it, as there is also the way with the constants or
> EXT:xxx-syntax.

You used it here:

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

which is the most important call for loading the TYPO3-framework.

> Ok, switching to cli_dispatch is no problem, only missing documentation. But
> all is done in lowlevel, so these parts could be copied.

lowlevel is just one specific CLI application, your own don't have
anything to do with that. I don't see how they are related, they only
use the same API.

> So little additional question, how can I access commandline parameters? e.g.
> i want to start my script this way
> /abspath/typo3/cli_dispatch.phpsh mysscript -f 100

You pass $_SERVER['argv'] to your main() method of your class and it can
handle the command line the way it wishes. AFAIK we don't have any
getopt()-like functionality in TYPO3-core, so you have to do it your own
way.

Cheers,
Ernesto
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: HowTo: Running a cronscript using TYPO3 with CLI

by Steffen Kamper-2 :: Rate this Message:

| View Threaded | Show Only this Message


"Ernesto Baschny [cron IT]" <ernst@...> schrieb im Newsbeitrag
news:mailman.1.1199376508.29585.typo3-dev@......

> Steffen Kamper wrote: on 03.01.2008 16:54:
>
>> So little additional question, how can I access commandline parameters?
>> e.g.
>> i want to start my script this way
>> /abspath/typo3/cli_dispatch.phpsh mysscript -f 100
>
> You pass $_SERVER['argv'] to your main() method of your class and it can
> handle the command line the way it wishes. AFAIK we don't have any
> getopt()-like functionality in TYPO3-core, so you have to do it your own
> way.
>
> Cheers,
> Ernesto

I found something usable:
t3lib_cli::cli_getArgArray($option,$argv)

i will test a bit with this and may be make a demo-ext, thx for your hints.

vg  Steffen


_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: HowTo: Running a cronscript using TYPO3 with CLI

by Steffen Ritter-2 :: Rate this Message:

| View Threaded | Show Only this Message

Steffen Kamper schrieb:

> "Ernesto Baschny [cron IT]" <ernst@...> schrieb im Newsbeitrag
> news:mailman.1.1199376508.29585.typo3-dev@......
>> Steffen Kamper wrote: on 03.01.2008 16:54:
>>
>>> So little additional question, how can I access commandline parameters?
>>> e.g.
>>> i want to start my script this way
>>> /abspath/typo3/cli_dispatch.phpsh mysscript -f 100
>> You pass $_SERVER['argv'] to your main() method of your class and it can
>> handle the command line the way it wishes. AFAIK we don't have any
>> getopt()-like functionality in TYPO3-core, so you have to do it your own
>> way.
>>
>> Cheers,
>> Ernesto
>
> I found something usable:
> t3lib_cli::cli_getArgArray($option,$argv)
>
> i will test a bit with this and may be make a demo-ext, thx for your hints.
>
> vg  Steffen
>
>
Fascinated by your discussion i tried the hole afternoon to create an
own CLI Script using the cli_dispath.php.
Against the information in
typo3/sysext/lowlevel/HOWTO_clean_up_TYPO3_installations.txt it does not
work as written in this Document. At the moment I'm going throug all
files which are included while CLI and checking what happens.
When finished I will report what I had to do, and publish some kind of
"Howto"...

mfG

Steffen

_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: HowTo: Running a cronscript using TYPO3 with CLI

by Steffen Kamper-2 :: Rate this Message:

| View Threaded | Show Only this Message

Hi Steffen,

it's very easy, here is a very very basic one
===============================
create BE user _cli_cronjob

in ext_localconf.php:
//register key for cli
$TYPO3_CONF_VARS['SC_OPTIONS']['GLOBAL']['cliKeys']['mycliscript']=
array('EXT:myext/croncli.php','_CLI_cronjob');

the croncli.php:

if (!defined('TYPO3_cliMode')) die('You cannot run this script directly!');

require_once(PATH_t3lib.'class.t3lib_cli.php');

class tx_myjobs extends t3lib_cli {

 function main($argv) {
  $args = $this->cli_getArgArray('-f',$argv);
  print_r($args);
 }
}

 // Call the functionality
$myObj = t3lib_div::makeInstance('tx_myjobs');
$myObj->main($_SERVER["argv"]);
===============================

then call it on console:
/var/www/.../typo3/cli_dispatch.phpsh mycliscript -f hello

works.

vg  Steffen

"Steffen Ritter" <info@...> schrieb im Newsbeitrag
news:mailman.1.1199387764.1420.typo3-dev@......

> Steffen Kamper schrieb:
>> "Ernesto Baschny [cron IT]" <ernst@...> schrieb im Newsbeitrag
>> news:mailman.1.1199376508.29585.typo3-dev@......
>>> Steffen Kamper wrote: on 03.01.2008 16:54:
>>>
>>>> So little additional question, how can I access commandline parameters?
>>>> e.g.
>>>> i want to start my script this way
>>>> /abspath/typo3/cli_dispatch.phpsh mysscript -f 100
>>> You pass $_SERVER['argv'] to your main() method of your class and it can
>>> handle the command line the way it wishes. AFAIK we don't have any
>>> getopt()-like functionality in TYPO3-core, so you have to do it your own
>>> way.
>>>
>>> Cheers,
>>> Ernesto
>>
>> I found something usable:
>> t3lib_cli::cli_getArgArray($option,$argv)
>>
>> i will test a bit with this and may be make a demo-ext, thx for your
>> hints.
>>
>> vg  Steffen
> Fascinated by your discussion i tried the hole afternoon to create an own
> CLI Script using the cli_dispath.php.
> Against the information in
> typo3/sysext/lowlevel/HOWTO_clean_up_TYPO3_installations.txt it does not
> work as written in this Document. At the moment I'm going throug all files
> which are included while CLI and checking what happens.
> When finished I will report what I had to do, and publish some kind of
> "Howto"...
>
> mfG
>
> Steffen
>


_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: HowTo: Running a cronscript using TYPO3 with CLI

by Steffen Ritter-2 :: Rate this Message:

| View Threaded | Show Only this Message

Steffen Kamper schrieb:

> Hi Steffen,
>
> it's very easy, here is a very very basic one
> ===============================
> create BE user _cli_cronjob
>
> in ext_localconf.php:
> //register key for cli
> $TYPO3_CONF_VARS['SC_OPTIONS']['GLOBAL']['cliKeys']['mycliscript']=
> array('EXT:myext/croncli.php','_CLI_cronjob');
>
> the croncli.php:
>
> if (!defined('TYPO3_cliMode')) die('You cannot run this script directly!');
>
> require_once(PATH_t3lib.'class.t3lib_cli.php');
>
> class tx_myjobs extends t3lib_cli {
>
>  function main($argv) {
>   $args = $this->cli_getArgArray('-f',$argv);
>   print_r($args);
>  }
> }
>
>  // Call the functionality
> $myObj = t3lib_div::makeInstance('tx_myjobs');
> $myObj->main($_SERVER["argv"]);
> ===============================
>
> then call it on console:
> /var/www/.../typo3/cli_dispatch.phpsh mycliscript -f hello
>
> works.
>
> vg  Steffen
>
> "Steffen Ritter" <info@...> schrieb im Newsbeitrag
> news:mailman.1.1199387764.1420.typo3-dev@......
>> Steffen Kamper schrieb:
>>> "Ernesto Baschny [cron IT]" <ernst@...> schrieb im Newsbeitrag
>>> news:mailman.1.1199376508.29585.typo3-dev@......
>>>> Steffen Kamper wrote: on 03.01.2008 16:54:
>>>>
>>>>> So little additional question, how can I access commandline parameters?
>>>>> e.g.
>>>>> i want to start my script this way
>>>>> /abspath/typo3/cli_dispatch.phpsh mysscript -f 100
>>>> You pass $_SERVER['argv'] to your main() method of your class and it can
>>>> handle the command line the way it wishes. AFAIK we don't have any
>>>> getopt()-like functionality in TYPO3-core, so you have to do it your own
>>>> way.
>>>>
>>>> Cheers,
>>>> Ernesto
>>> I found something usable:
>>> t3lib_cli::cli_getArgArray($option,$argv)
>>>
>>> i will test a bit with this and may be make a demo-ext, thx for your
>>> hints.
>>>
>>> vg  Steffen
>> Fascinated by your discussion i tried the hole afternoon to create an own
>> CLI Script using the cli_dispath.php.
>> Against the information in
>> typo3/sysext/lowlevel/HOWTO_clean_up_TYPO3_installations.txt it does not
>> work as written in this Document. At the moment I'm going throug all files
>> which are included while CLI and checking what happens.
>> When finished I will report what I had to do, and publish some kind of
>> "Howto"...
>>
>> mfG
>>
>> Steffen
>>
>
>
Okay, this looks quite good. The HowTo tells to extend the
lowlevel_core, which did not work. The rest of my work is like your
explenaiton. So i gonna change my classes, and will tell, what happened.

PRobably there should be a Howto on typo3.org or a possibility to start
CLI Interface in Kickstarter.
If I gonna publish one or both of this, how should I talk to for use?

mfG

Steffen
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: HowTo: Running a cronscript using TYPO3 with CLI

by Steffen Kamper-2 :: Rate this Message:

| View Threaded | Show Only this Message


"Steffen Ritter" <info@...> schrieb im Newsbeitrag
news:mailman.1.1199432609.25560.typo3-dev@......

> Steffen Kamper schrieb:
>> Hi Steffen,
>>
>> it's very easy, here is a very very basic one
>> ===============================
>> create BE user _cli_cronjob
>>
>> in ext_localconf.php:
>> //register key for cli
>> $TYPO3_CONF_VARS['SC_OPTIONS']['GLOBAL']['cliKeys']['mycliscript']=
>> array('EXT:myext/croncli.php','_CLI_cronjob');
>>
>> the croncli.php:
>>
>> if (!defined('TYPO3_cliMode')) die('You cannot run this script
>> directly!');
>>
>> require_once(PATH_t3lib.'class.t3lib_cli.php');
>>
>> class tx_myjobs extends t3lib_cli {
>>
>>  function main($argv) {
>>   $args = $this->cli_getArgArray('-f',$argv);
>>   print_r($args);
>>  }
>> }
>>
>>  // Call the functionality
>> $myObj = t3lib_div::makeInstance('tx_myjobs');
>> $myObj->main($_SERVER["argv"]);
>> ===============================
>>
>> then call it on console:
>> /var/www/.../typo3/cli_dispatch.phpsh mycliscript -f hello
>>
>> works.
>>
>> vg  Steffen
>>
>> "Steffen Ritter" <info@...> schrieb im Newsbeitrag
>> news:mailman.1.1199387764.1420.typo3-dev@......
>>> Steffen Kamper schrieb:
>>>> "Ernesto Baschny [cron IT]" <ernst@...> schrieb im Newsbeitrag
>>>> news:mailman.1.1199376508.29585.typo3-dev@......
>>>>> Steffen Kamper wrote: on 03.01.2008 16:54:
>>>>>
>>>>>> So little additional question, how can I access commandline
>>>>>> parameters? e.g.
>>>>>> i want to start my script this way
>>>>>> /abspath/typo3/cli_dispatch.phpsh mysscript -f 100
>>>>> You pass $_SERVER['argv'] to your main() method of your class and it
>>>>> can
>>>>> handle the command line the way it wishes. AFAIK we don't have any
>>>>> getopt()-like functionality in TYPO3-core, so you have to do it your
>>>>> own
>>>>> way.
>>>>>
>>>>> Cheers,
>>>>> Ernesto
>>>> I found something usable:
>>>> t3lib_cli::cli_getArgArray($option,$argv)
>>>>
>>>> i will test a bit with this and may be make a demo-ext, thx for your
>>>> hints.
>>>>
>>>> vg  Steffen
>>> Fascinated by your discussion i tried the hole afternoon to create an
>>> own CLI Script using the cli_dispath.php.
>>> Against the information in
>>> typo3/sysext/lowlevel/HOWTO_clean_up_TYPO3_installations.txt it does not
>>> work as written in this Document. At the moment I'm going throug all
>>> files which are included while CLI and checking what happens.
>>> When finished I will report what I had to do, and publish some kind of
>>> "Howto"...
>>>
>>> mfG
>>>
>>> Steffen
>>>
>>
>>
> Okay, this looks quite good. The HowTo tells to extend the lowlevel_core,
> which did not work. The rest of my work is like your explenaiton. So i
> gonna change my classes, and will tell, what happened.
>
> PRobably there should be a Howto on typo3.org or a possibility to start
> CLI Interface in Kickstarter.
> If I gonna publish one or both of this, how should I talk to for use?
>
> mfG
>
> Steffen

for changing Kickstarter or Documentation make a BT-entry and a RFC in core
list.

vg  Steffen


_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: HowTo: Running a cronscript using TYPO3 with CLI

by Dan Osipov :: Rate this Message:

| View Threaded | Show Only this Message

I would also like to request a how-to/guide for setting up something similar Windows using Scheduled Tasks.
 
Unfortunately some of us have to run Typo3 in the Windows environment...
 
Dan Osipov

________________________________

From: typo3-dev-bounces@... on behalf of Steffen Ritter
Sent: Fri 1/4/2008 2:43 AM
To: typo3-dev@...
Subject: Re: [TYPO3-dev] HowTo: Running a cronscript using TYPO3 with CLI



Steffen Kamper schrieb:

> Hi Steffen,
>
> it's very easy, here is a very very basic one
> ===============================
> create BE user _cli_cronjob
>
> in ext_localconf.php:
> //register key for cli
> $TYPO3_CONF_VARS['SC_OPTIONS']['GLOBAL']['cliKeys']['mycliscript']=
> array('EXT:myext/croncli.php','_CLI_cronjob');
>
> the croncli.php:
>
> if (!defined('TYPO3_cliMode')) die('You cannot run this script directly!');
>
> require_once(PATH_t3lib.'class.t3lib_cli.php');
>
> class tx_myjobs extends t3lib_cli {
>
>  function main($argv) {
>   $args = $this->cli_getArgArray('-f',$argv);
>   print_r($args);
>  }
> }
>
>  // Call the functionality
> $myObj = t3lib_div::makeInstance('tx_myjobs');
> $myObj->main($_SERVER["argv"]);
> ===============================
>
> then call it on console:
> /var/www/.../typo3/cli_dispatch.phpsh mycliscript -f hello
>
> works.
>
> vg  Steffen
>
> "Steffen Ritter" <info@...> schrieb im Newsbeitrag
> news:mailman.1.1199387764.1420.typo3-dev@......
>> Steffen Kamper schrieb:
>>> "Ernesto Baschny [cron IT]" <ernst@...> schrieb im Newsbeitrag
>>> news:mailman.1.1199376508.29585.typo3-dev@......
>>>> Steffen Kamper wrote: on 03.01.2008 16:54:
>>>>
>>>>> So little additional question, how can I access commandline parameters?
>>>>> e.g.
>>>>> i want to start my script this way
>>>>> /abspath/typo3/cli_dispatch.phpsh mysscript -f 100
>>>> You pass $_SERVER['argv'] to your main() method of your class and it can
>>>> handle the command line the way it wishes. AFAIK we don't have any
>>>> getopt()-like functionality in TYPO3-core, so you have to do it your own
>>>> way.
>>>>
>>>> Cheers,
>>>> Ernesto
>>> I found something usable:
>>> t3lib_cli::cli_getArgArray($option,$argv)
>>>
>>> i will test a bit with this and may be make a demo-ext, thx for your
>>> hints.
>>>
>>> vg  Steffen
>> Fascinated by your discussion i tried the hole afternoon to create an own
>> CLI Script using the cli_dispath.php.
>> Against the information in
>> typo3/sysext/lowlevel/HOWTO_clean_up_TYPO3_installations.txt it does not
>> work as written in this Document. At the moment I'm going throug all files
>> which are included while CLI and checking what happens.
>> When finished I will report what I had to do, and publish some kind of
>> "Howto"...
>>
>> mfG
>>
>> Steffen
>>
>
>
Okay, this looks quite good. The HowTo tells to extend the
lowlevel_core, which did not work. The rest of my work is like your
explenaiton. So i gonna change my classes, and will tell, what happened.

PRobably there should be a Howto on typo3.org or a possibility to start
CLI Interface in Kickstarter.
If I gonna publish one or both of this, how should I talk to for use?

mfG

Steffen
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev





_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: HowTo: Running a cronscript using TYPO3 with CLI

by Alban Cousinié :: Rate this Message:

| View Threaded | Show Only this Message

> Unfortunately some of us have to run Typo3 in the Windows
> environment...

On windows you can use the task scheduler to run tasks on repetitive
scheduled times. It works just as well as cron. You can specify tasks from
the command line using command 'at'. For more info on this command, see
http://support.microsoft.com/kb/313565


> -----Message d'origine-----
> De : typo3-dev-bounces@... [mailto:typo3-dev-
> bounces@...] De la part de Osipov Dan
> Envoyé : samedi 5 janvier 2008 05:42
> À : List for Core-/Extension development
> Objet : Re: [TYPO3-dev] HowTo: Running a cronscript using TYPO3 with
> CLI
>
> I would also like to request a how-to/guide for setting up something
> similar Windows using Scheduled Tasks.
>
> Unfortunately some of us have to run Typo3 in the Windows
> environment...
>
> Dan Osipov
>
> ________________________________
>
> From: typo3-dev-bounces@... on behalf of Steffen
> Ritter
> Sent: Fri 1/4/2008 2:43 AM
> To: typo3-dev@...
> Subject: Re: [TYPO3-dev] HowTo: Running a cronscript using TYPO3 with
> CLI
>
>
>
> Steffen Kamper schrieb:
> > Hi Steffen,
> >
> > it's very easy, here is a very very basic one
> > =============================== create BE user _cli_cronjob
> >
> > in ext_localconf.php:
> > //register key for cli
> > $TYPO3_CONF_VARS['SC_OPTIONS']['GLOBAL']['cliKeys']['mycliscript']=
> > array('EXT:myext/croncli.php','_CLI_cronjob');
> >
> > the croncli.php:
> >
> > if (!defined('TYPO3_cliMode')) die('You cannot run this script
> > directly!');
> >
> > require_once(PATH_t3lib.'class.t3lib_cli.php');
> >
> > class tx_myjobs extends t3lib_cli {
> >
> >  function main($argv) {
> >   $args = $this->cli_getArgArray('-f',$argv);
> >   print_r($args);
> >  }
> > }
> >
> >  // Call the functionality
> > $myObj = t3lib_div::makeInstance('tx_myjobs');
> > $myObj->main($_SERVER["argv"]);
> > ===============================
> >
> > then call it on console:
> > /var/www/.../typo3/cli_dispatch.phpsh mycliscript -f hello
> >
> > works.
> >
> > vg  Steffen
> >
> > "Steffen Ritter" <info@...> schrieb im Newsbeitrag
> > news:mailman.1.1199387764.1420.typo3-dev@......
> >> Steffen Kamper schrieb:
> >>> "Ernesto Baschny [cron IT]" <ernst@...> schrieb im
> >>> Newsbeitrag news:mailman.1.1199376508.29585.typo3-
> dev@......
> >>>> Steffen Kamper wrote: on 03.01.2008 16:54:
> >>>>
> >>>>> So little additional question, how can I access commandline
> parameters?
> >>>>> e.g.
> >>>>> i want to start my script this way
> >>>>> /abspath/typo3/cli_dispatch.phpsh mysscript -f 100
> >>>> You pass $_SERVER['argv'] to your main() method of your class and
> >>>> it can handle the command line the way it wishes. AFAIK we don't
> >>>> have any getopt()-like functionality in TYPO3-core, so you have to
> >>>> do it your own way.
> >>>>
> >>>> Cheers,
> >>>> Ernesto
> >>> I found something usable:
> >>> t3lib_cli::cli_getArgArray($option,$argv)
> >>>
> >>> i will test a bit with this and may be make a demo-ext, thx for
> your
> >>> hints.
> >>>
> >>> vg  Steffen
> >> Fascinated by your discussion i tried the hole afternoon to create
> an
> >> own CLI Script using the cli_dispath.php.
> >> Against the information in
> >> typo3/sysext/lowlevel/HOWTO_clean_up_TYPO3_installations.txt it does
> >> not work as written in this Document. At the moment I'm going throug
> >> all files which are included while CLI and checking what happens.
> >> When finished I will report what I had to do, and publish some kind
> >> of "Howto"...
> >>
> >> mfG
> >>
> >> Steffen
> >>
> >
> >
> Okay, this looks quite good. The HowTo tells to extend the
> lowlevel_core, which did not work. The rest of my work is like your
> explenaiton. So i gonna change my classes, and will tell, what
> happened.
>
> PRobably there should be a Howto on typo3.org or a possibility to start
> CLI Interface in Kickstarter.
> If I gonna publish one or both of this, how should I talk to for use?
>
> mfG
>
> Steffen
> _______________________________________________
> TYPO3-dev mailing list
> TYPO3-dev@...
> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev
>
>
>


_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: HowTo: Running a cronscript using TYPO3 with CLI

by Dan Osipov :: Rate this Message:

| View Threaded | Show Only this Message

Right, I have no problems scheduling script execution, but I am having problems executing cli_dispatch.phpsh. It doesn't seem to work...
 
That's why it would be helpful if a how to guide for a cron setup also included a section for Windows users.
 
Dan

________________________________

From: typo3-dev-bounces@... on behalf of Alban Cousinié
Sent: Sat 1/5/2008 3:23 AM
To: 'List for Core-/Extension development'
Subject: Re: [TYPO3-dev] HowTo: Running a cronscript using TYPO3 with CLI



> Unfortunately some of us have to run Typo3 in the Windows
> environment...

On windows you can use the task scheduler to run tasks on repetitive
scheduled times. It works just as well as cron. You can specify tasks from
the command line using command 'at'. For more info on this command, see
http://support.microsoft.com/kb/313565


> -----Message d'origine-----
> De : typo3-dev-bounces@... [mailto:typo3-dev-
> bounces@...] De la part de Osipov Dan
> Envoyé : samedi 5 janvier 2008 05:42
> À : List for Core-/Extension development
> Objet : Re: [TYPO3-dev] HowTo: Running a cronscript using TYPO3 with
> CLI
>
> I would also like to request a how-to/guide for setting up something
> similar Windows using Scheduled Tasks.
>
> Unfortunately some of us have to run Typo3 in the Windows
> environment...
>
> Dan Osipov
>
> ________________________________
>
> From: typo3-dev-bounces@... on behalf of Steffen
> Ritter
> Sent: Fri 1/4/2008 2:43 AM
> To: typo3-dev@...
> Subject: Re: [TYPO3-dev] HowTo: Running a cronscript using TYPO3 with
> CLI
>
>
>
> Steffen Kamper schrieb:
> > Hi Steffen,
> >
> > it's very easy, here is a very very basic one
> > =============================== create BE user _cli_cronjob
> >
> > in ext_localconf.php:
> > //register key for cli
> > $TYPO3_CONF_VARS['SC_OPTIONS']['GLOBAL']['cliKeys']['mycliscript']=
> > array('EXT:myext/croncli.php','_CLI_cronjob');
> >
> > the croncli.php:
> >
> > if (!defined('TYPO3_cliMode')) die('You cannot run this script
> > directly!');
> >
> > require_once(PATH_t3lib.'class.t3lib_cli.php');
> >
> > class tx_myjobs extends t3lib_cli {
> >
> >  function main($argv) {
> >   $args = $this->cli_getArgArray('-f',$argv);
> >   print_r($args);
> >  }
> > }
> >
> >  // Call the functionality
> > $myObj = t3lib_div::makeInstance('tx_myjobs');
> > $myObj->main($_SERVER["argv"]);
> > ===============================
> >
> > then call it on console:
> > /var/www/.../typo3/cli_dispatch.phpsh mycliscript -f hello
> >
> > works.
> >
> > vg  Steffen
> >
> > "Steffen Ritter" <info@...> schrieb im Newsbeitrag
> > news:mailman.1.1199387764.1420.typo3-dev@......
> >> Steffen Kamper schrieb:
> >>> "Ernesto Baschny [cron IT]" <ernst@...> schrieb im
> >>> Newsbeitrag news:mailman.1.1199376508.29585.typo3-
> dev@......
> >>>> Steffen Kamper wrote: on 03.01.2008 16:54:
> >>>>
> >>>>> So little additional question, how can I access commandline
> parameters?
> >>>>> e.g.
> >>>>> i want to start my script this way
> >>>>> /abspath/typo3/cli_dispatch.phpsh mysscript -f 100
> >>>> You pass $_SERVER['argv'] to your main() method of your class and
> >>>> it can handle the command line the way it wishes. AFAIK we don't
> >>>> have any getopt()-like functionality in TYPO3-core, so you have to
> >>>> do it your own way.
> >>>>
> >>>> Cheers,
> >>>> Ernesto
> >>> I found something usable:
> >>> t3lib_cli::cli_getArgArray($option,$argv)
> >>>
> >>> i will test a bit with this and may be make a demo-ext, thx for
> your
> >>> hints.
> >>>
> >>> vg  Steffen
> >> Fascinated by your discussion i tried the hole afternoon to create
> an
> >> own CLI Script using the cli_dispath.php.
> >> Against the information in
> >> typo3/sysext/lowlevel/HOWTO_clean_up_TYPO3_installations.txt it does
> >> not work as written in this Document. At the moment I'm going throug
> >> all files which are included while CLI and checking what happens.
> >> When finished I will report what I had to do, and publish some kind
> >> of "Howto"...
> >>
> >> mfG
> >>
> >> Steffen
> >>
> >
> >
> Okay, this looks quite good. The HowTo tells to extend the
> lowlevel_core, which did not work. The rest of my work is like your
> explenaiton. So i gonna change my classes, and will tell, what
> happened.
>
> PRobably there should be a Howto on typo3.org or a possibility to start
> CLI Interface in Kickstarter.
> If I gonna publish one or both of this, how should I talk to for use?
>
> mfG
>
> Steffen
> _______________________________________________
> TYPO3-dev mailing list
> TYPO3-dev@...
> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev
>
>
>

_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev





_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: HowTo: Running a cronscript using TYPO3 with CLI

by Martin Kutschker-4 :: Rate this Message:

| View Threaded | Show Only this Message

Osipov Dan schrieb:
> Right, I have no problems scheduling script execution, but I am having problems executing cli_dispatch.phpsh. It doesn't seem to work...
>  
> That's why it would be helpful if a how to guide for a cron setup also included a section for Windows users.

Wait, on Windows you have at least to use a full path to your script
like "php C:\www\typo3\cli_dispacth.php". But I think it's broken
completely. Have a look at the Core list archive for suggestions how to
fix this.

Masi
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: HowTo: Running a cronscript using TYPO3 with CLI

by Steffen Ritter-2 :: Rate this Message:

| View Threaded | Show Only this Message

Martin Kutschker schrieb:

> Osipov Dan schrieb:
>> Right, I have no problems scheduling script execution, but I am having
>> problems executing cli_dispatch.phpsh. It doesn't seem to work...
>>  
>> That's why it would be helpful if a how to guide for a cron setup also
>> included a section for Windows users.
>
> Wait, on Windows you have at least to use a full path to your script
> like "php C:\www\typo3\cli_dispacth.php". But I think it's broken
> completely. Have a look at the Core list archive for suggestions how to
> fix this.
>
> Masi
I think you can't call the script directly without changing it on
windows. Because of the first line which is unix style interpreter name.
Remove this line, so that the dispatcher.phpsh is only php code, and it
should work(if you call with the full path as said before).

Steffen
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: HowTo: Running a cronscript using TYPO3 with CLI

by Martin Kutschker-2 :: Rate this Message:

| View Threaded | Show Only this Message

Steffen Ritter schrieb:

> Martin Kutschker schrieb:
>> Osipov Dan schrieb:
>>> Right, I have no problems scheduling script execution, but I am
>>> having problems executing cli_dispatch.phpsh. It doesn't seem to work...
>>>  
>>> That's why it would be helpful if a how to guide for a cron setup
>>> also included a section for Windows users.
>>
>> Wait, on Windows you have at least to use a full path to your script
>> like "php C:\www\typo3\cli_dispacth.php". But I think it's broken
>> completely. Have a look at the Core list archive for suggestions how
>> to fix this.
>>
>> Masi
> I think you can't call the script directly without changing it on
> windows. Because of the first line which is unix style interpreter name.

You can call it via "php <script>" name regardless of the first line. The
real problem is somewhere below where a resolving of a relative path
working only on Unix breaks on Windows.

Masi
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: HowTo: Running a cronscript using TYPO3 with CLI

by Ernesto Baschny [cron IT] :: Rate this Message:

| View Threaded | Show Only this Message

Steffen Ritter wrote: on 06.01.2008 13:51:

> Martin Kutschker schrieb:
>> Osipov Dan schrieb:
>>> Right, I have no problems scheduling script execution, but I am
>>> having problems executing cli_dispatch.phpsh. It doesn't seem to work...
>>>  
>>> That's why it would be helpful if a how to guide for a cron setup
>>> also included a section for Windows users.
>>
>> Wait, on Windows you have at least to use a full path to your script
>> like "php C:\www\typo3\cli_dispacth.php". But I think it's broken
>> completely. Have a look at the Core list archive for suggestions how
>> to fix this.
>>
>> Masi
> I think you can't call the script directly without changing it on
> windows. Because of the first line which is unix style interpreter name.
> Remove this line, so that the dispatcher.phpsh is only php code, and it
> should work(if you call with the full path as said before).

AFAIK the first line won't matter to Windows, as it will always call it
through the php.exe interpreter. And my guess is that php.exe will skip
that commented line.

The suggestion to fix this is the "pending patch" in the core list:

Thread "RFC: Bug #5838: cli_dispatch.phpsh not working with windows"
from 16.7.2007 and http://bugs.typo3.org/view.php?id=5838. See if the
attached patch on that thread solves the issue on Windows (calling the
script in Windows with a full path. If it does, please comment on that
in the core list, so we might integrate at least that fix into core for 4.2.

Cheers,
Ernesto
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev
< Prev | 1 - 2 | Next >