I'm trying to create an API app that logs into a router and creates a script, then runs that script. The problem is that I can only do a single line at at a time. When I use "\n" or "\r\n" inside the PHP API app text, the result created under /system/script is everything before the first backslash and nothing after it.
Here is my code:
Code: Select all
$API->write("/system/script/add
=name=test1
=source=:log info test \r\n test
");
test router] > system script print
Flags: I - invalid
0 name="test1" owner="admin" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon
run-count=0 source=:log info test
Any ideas? I have tried many variations and have read that the escaped characters in PHP only work with double quotes so I am aware of this issue but routerOS doesn't seem to handle them correctly anyway.
If I run this command in the router terminal, it works perferctly:
system script add name=test2 source=":log info test \r\n test"