Comments (5)
Hello! I've not used scripts of ROS previously, can you provide sample of how to create it and how to use it?
from routeros-api-php.
hi @EvilFreelancer
thank you for responding to my question. actually I'm not really sure either. at the moment I am just trying to experiment for my small project. I plan to write a script like this:
$config = (new Config())
->set('timeout',1)
->set('host', '192.168.88.1')
->set('user', 'admin')
->set('pass', '');
$client = new Client($config);
$create = $client->write(['/system/script/add', "=name=test_by_system2",'=source=:local monitor [/interface monitor-traffic ether2 as-value once] \r\n
:local speedRX ($monitor->"rx-bits-per-second")\r\n
:local speedTX ($monitor->"tx-bits-per-second")\r\n
/tool fetch mode=http url=("http://192.168.254.72/micro-nms/storebw/1/$speedTX/$speedRX") keep-result=no'])->read();
and then i create scheduler by this way:
$config = (new Config())
->set('timeout',1)
->set('host', $params[1])
->set('user', $params[2])
->set('pass', $params[3]);
$client = new Client($config);
$query = (new Query('/system/scheduler/add'))
->equal('name','monitoring22')
->equal('on-event','monitoring')
->equal('interval','1s')
->equal('start-time','startup');
$response = $client->write($query)->read();
until here all went well, the problem arises when I want to display the script that I wrote before. in the following way
$config = (new Config())
->set('timeout',1)
->set('host', $params[1])
->set('user', $params[2])
->set('pass', $params[3]);
$client = new Client($config);
$scriptQue = (new Query('/system/script/print'));
$scriptReq = $client->write($scriptQue);
$script = $client->read();
and this method works, but not the results can not display the full script, this method only displays the first 1 line of code. I do not understand what's wrong.
previously I apologize if the English I use is not good
from routeros-api-php.
Okay, ill check it from my side.
Btw, you can try to use ->read(true)
instead ->read()
method, it will return unparsed results.
And do not worry about English, I'm also is not a native speaker :)
from routeros-api-php.
Hello! I've checked your issue (sorry for so long response, very hard to find spare time).
If I understand correctly, you have some issue with creating system scripts, your solution show me shorted version of line which you want to call via scheduller, you need slightly change line (add line concatenation) and everything will work.
I've created small example by your code, which should show what everything is almost okay, but need to add small fix.
from routeros-api-php.
hi @EvilFreelancer, thank you for the solution. I really appreciate the effort and time you spent helping me.
from routeros-api-php.
Related Issues (20)
- Got stuck when device is not available
- How to handle response error properly? HOT 1
- Is there any way to get a user total download upload size of data? HOT 1
- Wol HOT 2
- /export does not work ROUTEROS7 HOT 3
- done HOT 1
- Stream timed out error HOT 4
- Why not connecting in live server? HOT 2
- windows Socket timeout reached HOT 4
- Unable to establish socket session, some sort of timeout error. HOT 3
- Random Stream timed out HOT 1
- Insert Query on RouterOS HOT 2
- Upgrade phpseclib HOT 7
- Why is it that when I try to use local it's fine, whereas when I try to upload it on the cpanel liveserver it can't connect HOT 3
- Can I fill the `host` not with IPv4 but with domain ? like tunnel.web.id ? HOT 2
- remove pppoe active not work HOT 1
- PHP Version Support HOT 2
- Problem executing a query HOT 1
- works with angular or nextjs frontend? HOT 1
- RestAPI HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from routeros-api-php.