Adding scheduler 'on-event' two line script problem.

Hi,

I’m trying to add into scheduler → ‘on-event’ two lines using php class (http://wiki.mikrotik.com/wiki/API_PHP_class) by code:

$api->comm(‘/system/scheduler/add’, array(
“name” => ‘upgrade_system’,
“interval” => ‘5s’,
“on-event” => “/system scheduler remove upgrade_system.
/system identity set name=‘system upgraded’” ));

but the second line of “on-event” is not transfered to MT. The debug mode shows below information:

Connection attempt #1 to 185.118.213.50:8728…
<<< [6] /login

[5/5] bytes read.
[5, 39]!done
[37/37] bytes read.
[37, 1]=ret=2d2412e5c9f35879f264274b091be9d2
<<< [6] /login
<<< [11] =name=admin
<<< [44] =response=007513c6ac0e7e68356cc16ce3f652aa09
[5/5] bytes read.
[5, 1]!done
Connected…
<<< [21] /system/scheduler/add
<<< [20] =name=upgrade_system
<<< [12] =interval=5s
<<< [49] =on-event=/system scheduler remove upgrade_system
<<< [32] /system identity set name=‘test’
[5/5] bytes read.
[5, 10]!done
[8/8] bytes read.
[8, 1]=ret=*82
Disconnected…

Please help in solving this problem.

br
Piotr Polok

I am just about to attempt something similar in one of my applications, but your code here seems to be pretty clear what the error is.
Much like you can’t do multiline strings in the console without using “\r\n” instead of newlines.

Try:

$api->comm('/system/scheduler/add', array(
       "name"     => 'upgrade_system',
       "interval" => '5s',
       "on-event" => "/system scheduler remove upgrade_system.\r\n/system identity set name='system upgraded'" ));

May have to use double slashes, depending on how PHP handles it.

PS: If you are asking for help with the API (or specific API Library) add it to the thread’s title. You’ll get more help that way.

Thank’s for reply :wink:.