Git Product home page Git Product logo

Comments (5)

EvilFreelancer avatar EvilFreelancer commented on June 8, 2024

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.

ones006 avatar ones006 commented on June 8, 2024

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.

EvilFreelancer avatar EvilFreelancer commented on June 8, 2024

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.

EvilFreelancer avatar EvilFreelancer commented on June 8, 2024

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.

Screenshot_20191024_143005
Screenshot_20191024_142957

from routeros-api-php.

ones006 avatar ones006 commented on June 8, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.