Community discussions

 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Another RouterOS API Delphi Client

Fri May 01, 2009 9:03 pm

It's my API client realization for Delphi7. It implements execution of parallel queries which are easily handled due to database-like interface.

v1.3: Added support for RouterOS 6.43+ API login method
v1.2: Added basic support for API over TLS
v1.1: Added Delphi 2009 compatibility (thanks to Anton Ekermans for testing)

Wiki page: http://wiki.mikrotik.com/wiki/API_Delphi_Client
GitHub page: https://github.com/Chupaka/Delphi-RouterOS-API/releases

Direct links to files:
Delphi-RouterOS-API-1.3.zip: https://github.com/Chupaka/Delphi-Route ... e/v1.3.zip
APITest-source-1.3.zip: https://github.com/Chupaka/Delphi-Route ... ce-1.3.zip
APITest-1.3.exe: https://github.com/Chupaka/Delphi-Route ... st-1.3.exe
Last edited by Chupaka on Thu Jun 13, 2013 4:40 pm, edited 3 times in total.
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
clink
just joined
Posts: 23
Joined: Sun Mar 30, 2008 12:30 pm

Re: Another RouterOS API Delphi Client

Sun Jun 21, 2009 4:39 pm

Hi Chupaka

I am searching some one there can help developing an api to the routeros.

Would you contact me at dev (at) sealink dot dk

The final result should make a communication from a web portal interface to the routerboard for activating predefined scripts on the routerboard ex. could be

The interface, API and scripts will give a user ex. in the reception of a hotel a https page where he can login. On this page the hotel have all network plugs for meeting rooms.
The user pick a room "center stage east" and choose 6 hours from the drop down menu and a few other parameters like which bandwidth there are required.
When he click execute button then it should establish a connection by the API to the routeros and execute a script which is on the routerboard.

For further details about your consulting please contact me.

B/R
Kenneth
 
ekkas
Long time Member
Long time Member
Posts: 562
Joined: Mon Sep 26, 2005 1:01 pm
Location: South Africa

Re: Another RouterOS API Delphi Client

Wed Sep 30, 2009 1:00 pm

Is this unit D2009 compatible? Should I convert all String to AnsiString to avoid Unicode clashes?

Thanks
Ekkas
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Thu Nov 05, 2009 2:10 pm

New version 1.1: Delphi 2009 compatibility (thanks to Anton Ekermans for testing)
Requires Synapse Release 39
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Thu Nov 05, 2009 4:31 pm

oops... reuploaded with fixed typo in version history: it's Nov, not Oct :oops:
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
ekkas
Long time Member
Long time Member
Posts: 562
Joined: Mon Sep 26, 2005 1:01 pm
Location: South Africa

Re: Another RouterOS API Delphi Client

Sat Nov 07, 2009 3:30 am

Thanks a lot Chupaka, for your good work,
it will help me a lot.
 
lcosta
just joined
Posts: 2
Joined: Mon Jan 11, 2010 7:41 pm

Re: Another RouterOS API Delphi Client

Sat Jan 23, 2010 9:59 pm

Chupaka,
very good work with "RouterOSAPI.pas" I am a doubt, because not found any procedure in the engine ROSAPI for when the connection to incorrectly, you already did something for this case?? to be clearer for example when Winbox this running and for some reason it loses connectivity to the server then it terminates the application, I am trying to do that! you can help me?
 
lcosta
just joined
Posts: 2
Joined: Mon Jan 11, 2010 7:41 pm

Re: Another RouterOS API Delphi Client

Sat Jan 23, 2010 10:11 pm

It's my API client realization for Delphi7. It implements execution of parallel queries which are easily handled due to database-like interface.

v1.1: Added Delphi 2009 compatibility (thanks to Anton Ekermans for testing)

Wiki page: http://wiki.mikrotik.com/wiki/API_Delphi_Client
RouterOSAPI-1.1.zip
APITest-1.1.zip
APITest-Bin-1.1.zip
Chupak,

very good work with "RouterOSAPI.pas" I have some doubts, because not found in any procedure for ROSAPI engine stoped when the connection incorrectly, you already did something for this case?? to be clearer for example when Winbox this running and for some reason it loses connectivity to the server then it terminates the application, I am trying to do that! you can help me?
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Mon Jan 25, 2010 2:39 pm

unfortunately, there's no such functions. you may try to check Synapse Socket state directly
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
ekkas
Long time Member
Long time Member
Posts: 562
Joined: Mon Sep 26, 2005 1:01 pm
Location: South Africa

Re: Another RouterOS API Delphi Client

Mon Jan 25, 2010 4:43 pm

Hey Chupaka! Hope you're doing well...

I've been developing some very nice stuff with ROS to read info from my +-200 RBs, it's really great!
But I have a question:
How do I set a value using ROSAPI? e.g. i can read 'hw-protection-mode' by:
Res := ROS.Query(['/interface/wireless/print'], True);
if not Res.Trap
then begin
ShowMessage(Res['hw-protection-mode']);
end;
but how do I set the value to e.g. 'hw-protection-mode=rts-cts' ?


Anton Ekermans
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Mon Jan 25, 2010 5:06 pm

Res := ROS.Query(['/interface/wireless/set', '=.id=*bla-bla-bla', '=hw-protection-mode=HERE'], True);
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
ekkas
Long time Member
Long time Member
Posts: 562
Joined: Mon Sep 26, 2005 1:01 pm
Location: South Africa

Re: Another RouterOS API Delphi Client

Mon Jan 25, 2010 8:35 pm

Sorry for the trouble, but I run the command:
Res:=ROS.Query(['/interface/wireless/set', '=.id=*1234', '=hw-protection-mode=client-mode'], True);

It returns without error, but the value stays unchanged?
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Mon Jan 25, 2010 8:53 pm

just tested with v4.5...
/interface/wireless/print
=.proplist=.id,hw-protection-mode
returns
!re=
=.id=*6
=hw-protection-mode=none
now change hw-protection-mode:
/interface/wireless/set
=.id=*6
=hw-protection-mode=cts-to-self
and after that query again, response is
!re=
=.id=*6
=hw-protection-mode=cts-to-self
tested using 'APITest' application from the first post...
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
ekkas
Long time Member
Long time Member
Posts: 562
Joined: Mon Sep 26, 2005 1:01 pm
Location: South Africa

Re: Another RouterOS API Delphi Client

Mon Jan 25, 2010 9:19 pm

I did not bother using the .id returned from first query and just gave it a random number, I suppose that is my problem.
Thanks.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Mon Jan 25, 2010 9:24 pm

:D sure it is )))
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
hrico
just joined
Posts: 12
Joined: Wed Dec 16, 2009 2:25 am

Re: Another RouterOS API Delphi Client

Wed May 05, 2010 1:28 pm

To Chupaka:
Im trying do develop something similar in C# using the help from http://wiki.mikrotik.com/wiki/API_in_C_Sharp, but I have some problems concerning sending the requests:
I run the application, Login forms po-pup - input login,passwd, connect successfully, main application window is open.
And now if I want to execute(send) certain commands to the router I use the same function,which was used to create connection at the beginning but without login function. But then I get response from router about !fatalogin.
Is it necessary to use login and passwd, set at the beginning, to execute(send) each command sentence to the router? How do you do it?

Maybe I'm doing the whole thing wrong, but I thought it could work.

PS:I don't work with Delphi at all so your code does not really help me.
 
ekkas
Long time Member
Long time Member
Posts: 562
Joined: Mon Sep 26, 2005 1:01 pm
Location: South Africa

Re: Another RouterOS API Delphi Client

Wed May 05, 2010 1:52 pm

You shouldn't need to send the login info with each request, as long as you maintain (keep open) the same session/conection.
Once the session is authenticated, it should work on the same session.
Maybe you can generate an exact log of what you send/receive and post it here, that might be easier to see what's wrong as C code would not make any sense to a Delphi-only programmer like me either. (Or at least compare the log with the API wiki)

Ekkas
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6283
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Another RouterOS API Delphi Client

Thu May 06, 2010 9:09 am

anyway, if we see what output you have, we could say where is the problem.

And as previously said - basic steps are - make tcp/ip connection, authenticate w/ /login, send commands, close connection.
now every part in bit more detail
1) making of connection - easy part, simple connection
2) /login part - you have to follow the procedure carefully, getting challenge, forming reply and getting positive reply that you are in
3) sending commands - on each command you send you will get reply. if you use several commands that will run for some time (/ping, something with =follow=) use .tag, to tag replies
4) when you are done, terminate connection.
 
hrico
just joined
Posts: 12
Joined: Wed Dec 16, 2009 2:25 am

Re: Another RouterOS API Delphi Client

Thu May 06, 2010 11:02 am

Thanks for your replies.

I already got to the point 3 where I can send comands without problems(but only one at the same time) except these two:
/interface/monitor-traffic
/interface/wireless/scan

- the first one works only with argumnent once.
- is sth like once also by the scan?

I will be probably sending more request at the same time( for example I will monitor bandwidth and I will also want to get info about some interface..), so you think just to tag the reqest is enough? Because I was thinking about threading, where especially those commands like monitor,scan etc will be send through one of these threads.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Fri May 07, 2010 2:38 pm

hmmm... maybe the problem is you are waiting for '!done', but those command you should stop manually by '/cancel'?..
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
hrico
just joined
Posts: 12
Joined: Wed Dec 16, 2009 2:25 am

Re: Another RouterOS API Delphi Client

Sat May 08, 2010 11:57 am

Yes, you were right. When I debugged it I found out that it sends replies but never ends because there is no !done. But even if I put /cancel at the end, it never gets to this cancel.
mikrotik.Send("/interface/monitor-traffic");
mikrotik.Send("=interface=ether1");
mikrotik.Send("/cancel", true);
... is there any workaround?

I've used as a source this site http://wiki.mikrotik.com/wiki/API_in_C_Sharp.
Do you know maybe how to change the code so it would not always wait for this !done?
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Sun May 09, 2010 11:41 pm

you should execute your query, read necessary results and then stop it by executing "/cancel"
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
pro2
just joined
Posts: 16
Joined: Mon Apr 17, 2006 5:02 am

Re: Another RouterOS API Delphi Client

Tue Jan 25, 2011 7:13 pm

Gostaria de sabe como removo um linha no firewall, no ssh eu uso assim como faz o mesmo na api-delphi


"I would like to know how to remove a line in the firewall, I use ssh in and do the same in-api delphi"


/ip firewall nat remove [/ip firewall nat find src-address=10.0.0.1]
 
ekkas
Long time Member
Long time Member
Posts: 562
Joined: Mon Sep 26, 2005 1:01 pm
Location: South Africa

Re: Another RouterOS API Delphi Client

Wed Jan 26, 2011 9:15 am

There might be a shorter way, but I update address list by getting e.g.
/ip/firewall/address-list/print','?list=mylist'
Then parse the results an get the .id of the record I want to change.
Then do a
'ip/firewall/address-list/remove','=.id='+theid
Hope it helps.

Ekkas
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6283
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Another RouterOS API Delphi Client

Wed Jan 26, 2011 9:37 am

this basically is the way how you do that.

get the ID of the entry and remove by ID.
 
ekkas
Long time Member
Long time Member
Posts: 562
Joined: Mon Sep 26, 2005 1:01 pm
Location: South Africa

Re: Another RouterOS API Delphi Client

Wed Mar 02, 2011 12:49 am

when I do a 'query' from terminal window:
/tool user-manager user print count-only

I get an instant response, in this case 6925

But when I run API command:
Res:=ROS.Query(['/tool/user-manager/user/print','=count-only'],True);

Then it takes about 10 seconds to complete.
  • Am I doing the API command wrong?
    is it just how API works?
    Is it a possible new feature request?
Thanks
Ekkas
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Wed Mar 02, 2011 4:14 pm

do you have the same result in case of API?..
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
ekkas
Long time Member
Long time Member
Posts: 562
Joined: Mon Sep 26, 2005 1:01 pm
Location: South Africa

Re: Another RouterOS API Delphi Client

Wed Mar 02, 2011 4:27 pm

What do you mean?
Terminal= instant

API =very slow
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Wed Mar 02, 2011 4:33 pm

I mean, what do you receive in API response?
in both v4.2 and v5.0rc10 I get empty response if I try to use '=count-only' (I'm checking /ip/address/print) - seems like it doesn't work at all
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
ekkas
Long time Member
Long time Member
Posts: 562
Joined: Mon Sep 26, 2005 1:01 pm
Location: South Africa

Re: Another RouterOS API Delphi Client

Wed Mar 02, 2011 4:58 pm

Using your APItest:


Connected!
Version: 4.16
!done=
=ret=7145
----------------
================
APIcount.JPG
You do not have the required permissions to view the files attached to this post.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Wed Mar 02, 2011 6:11 pm

then you should write to support@, I believe :)

p.s. please mention that it doesn't work for /ip/address/print =)
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
ekkas
Long time Member
Long time Member
Posts: 562
Joined: Mon Sep 26, 2005 1:01 pm
Location: South Africa

Re: Another RouterOS API Delphi Client

Wed Mar 02, 2011 8:18 pm

I'll write to support.

It works for me on ip (ROS 4.16):
API2.JPG
You do not have the required permissions to view the files attached to this post.
Last edited by ekkas on Wed Mar 02, 2011 8:24 pm, edited 1 time in total.
 
ekkas
Long time Member
Long time Member
Posts: 562
Joined: Mon Sep 26, 2005 1:01 pm
Location: South Africa

Re: Another RouterOS API Delphi Client

Wed Mar 02, 2011 8:23 pm

And in ROS 5rc9:
API3.JPG
You do not have the required permissions to view the files attached to this post.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Thu Mar 03, 2011 12:55 am

argh, it's returned in the same sentence as '!done', so "Query & Listen" do not see it %) "Query & Get All" works fine, sorry for inconvenience :)
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
ekkas
Long time Member
Long time Member
Posts: 562
Joined: Mon Sep 26, 2005 1:01 pm
Location: South Africa

Re: Another RouterOS API Delphi Client

Thu Mar 03, 2011 12:59 am

No Problem. I always use getall. lol


Maybe you can help me with this one:
http://forum.mikrotik.com/viewtopic.php?f=9&t=49660
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6283
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Another RouterOS API Delphi Client

Thu Mar 03, 2011 1:44 pm

if i remember correctly, then some long time ago getall was an alias for print, so you get same stuff using getall or print commands using API, and for details you have to use =detail= (not so old change)
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Thu Mar 03, 2011 5:11 pm

for details you have to use =detail= (not so old change)
please correct the docs: http://wiki.mikrotik.com/wiki/API#Command_description
if .proplist is absent, all possible properties are included, even those that have slow access time (such as file contents and perfomance counters). Thus use of .proplist is encouraged. Omission of .proplist may have high perfomance penalty.
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6283
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Another RouterOS API Delphi Client

Mon Mar 07, 2011 11:16 am

thanks for pointing that out, wording has been updated.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Mon Mar 07, 2011 1:21 pm

huh, from the same place:
arguments that modify list of returned properties (detail, breif, ...) have no effect in the API
:)
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6283
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Another RouterOS API Delphi Client

Mon Mar 07, 2011 2:32 pm

edit-search-done. :oops:
 
tara
just joined
Posts: 6
Joined: Thu Dec 15, 2011 6:45 pm

Re: Another RouterOS API Delphi Client

Thu Dec 15, 2011 6:54 pm

hello. excuse my English.
how do I run this command because I have tried various ways and does not serve me.
ip hotspot active remove [/ip hotspot active find]
and tried and not working
ip/hotspot/active/remove 
=[=
=ip=
=hotspot=
=active=
=find=
=]=
or can give me a help to disconnect all active users in hotspot
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Fri Dec 16, 2011 1:08 am

how do I run this command because I have tried various ways and does not serve me.
ip hotspot active remove [/ip hotspot active find]
first,
/ip/hotspot/active/print
=.proplist=.id
then,
/ip/hotspot/active/remove
=.id=comma-separated-list-of-ids-from-prevoius-command-result
or can give me a help to disconnect all active users in hotspot
hmmm... maybe just disable HotSpot?..
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
gladiopeace
newbie
Posts: 37
Joined: Thu Dec 08, 2011 4:28 pm

Re: Another RouterOS API Delphi Client

Wed Aug 01, 2012 5:42 pm

hello how i can connect api via alternative api port?
best regards Gladio peace
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Wed Aug 01, 2012 5:45 pm

function Connect(const Hostname, Username, Password: AnsiString; const Port: AnsiString = '8728'): Boolean;
so, add a string parameter with port number after the password
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
gladiopeace
newbie
Posts: 37
Joined: Thu Dec 08, 2011 4:28 pm

Re: Another RouterOS API Delphi Client

Wed Aug 01, 2012 5:50 pm

Chupaka you're amazing, i love your beautiful mind:)
 
gladiopeace
newbie
Posts: 37
Joined: Thu Dec 08, 2011 4:28 pm

Re: Another RouterOS API Delphi Client

Fri Aug 03, 2012 9:10 pm

how i can set timeout for "ROS.Query"
kind regards Gladio Peace.
 
leonardocx
just joined
Posts: 3
Joined: Sat Sep 01, 2012 5:50 pm

Re: Another RouterOS API Delphi Client

Tue Sep 04, 2012 7:29 pm

I wonder how do I include the following eating via api, this command works fine in terminal via mikrotik wimbox


  / queue / simple / add name = "Leonardo Xavier" target-addresses = "192.168.2.34"
max-limit = "256K/256K" burst-limit = "512K/512K" burst-threshold = "256K/256K" burst-time = "60/6
0 "
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Fri Sep 07, 2012 2:49 pm

I wonder how do I include the following eating via api, this command works fine in terminal via mikrotik wimbox


  / queue / simple / add name = "Leonardo Xavier" target-addresses = "192.168.2.34"
max-limit = "256K/256K" burst-limit = "512K/512K" burst-threshold = "256K/256K" burst-time = "60/6
0 "
API and CLI (Terminal) are different things. in API, command should look like this:
/queue/simple/add
=name=Leonardo Xavier
=target-addresses=192.168.2.34
=max-limit=256000/256000
=burst-limit=512000/512000
=burst-threshold=256000/256000
=burst-time=60/60
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
leonardocx
just joined
Posts: 3
Joined: Sat Sep 01, 2012 5:50 pm

Re: Another RouterOS API Delphi Client

Wed Sep 19, 2012 11:49 pm

thank Chupaka
but solved this problem a few days ago, now I want to see if I can remove a client's specific mikrotik via its api, I'm having trouble with the command to locate the customer, and isolates it from the other, because the print command and not find me retronam via WinBox values ​​which can not hold a charge for this type of association as I did with the other commands, testing them in wimbox first.
Another thing about the backup could generate the file with the following command:

/ system / files / backup / save

the file appears in the files wimbox perfect as backup, but how to make a print this file in a memo field? even how to get this file?
 
ekkas
Long time Member
Long time Member
Posts: 562
Joined: Mon Sep 26, 2005 1:01 pm
Location: South Africa

Re: Another RouterOS API Delphi Client

Fri Oct 26, 2012 4:21 pm

Hey Chupaka
I have this component running great for a long time, since before Delphi 2009.
But there is a problem with multi-threading.
I put whole component inside a thread and sometimes, with few instances in different threads, connecting to different routers, all threads (or just 1) would just hang.
Almost like a lockup in critical section or something.
I could not pinpoint where it hang yet, but I thought maybe you could give me some pointer what I could look for, or maybe is it a limitation/bug in Syapse libs?

Thanks
Ekkas
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Sat Oct 27, 2012 5:45 pm

as far as I know, Synapse is being written with multi-threading in mind, so there should not be any problems in it...
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
darkdks
just joined
Posts: 3
Joined: Thu Dec 20, 2012 12:39 pm

Re: Another RouterOS API Delphi Client

Thu Dec 20, 2012 1:05 pm

Excellent work.
It's working fine for some purposes.
But it has a very serious bug (or maybe I'm not using correctly)
- if you are connected on mikrotik and
- if the mikrotik is unavailable(this can happen easily) and
- if you send a command for the router, the application will crash completely and not come back anymore. :(
To do a test like this is simple, connect in the RouterOS, disconnect the network cable or just a reboot in RouterOS and then send a command. The result will be disastrous =/
Any way to fix this problem?
ty.
 
darkdks
just joined
Posts: 3
Joined: Thu Dec 20, 2012 12:39 pm

Re: Another RouterOS API Delphi Client

Thu Dec 20, 2012 1:46 pm

I recorded a video for more detail, maybe my explanation was confusing.
I'm using the demo application to report. :)

[youtube]http://www.youtube.com/watch?v=jaiuJyeg0SA&f[/youtube]
 
darkdks
just joined
Posts: 3
Joined: Thu Dec 20, 2012 12:39 pm

Re: Another RouterOS API Delphi Client

Fri Dec 21, 2012 11:11 am

I do not believe to be the best solution, but that works fine for me.
I made a new function to send commands based on the former, with the difference that she always checks if the remote port is available before to send the query. If you can fix this another way is rly better, thanks!


Function Tfrm_ApiConect.SendAndGetAll(ComandoCmd: TStrings): String;
var
  Res: TRosApiResult;

  pa: array of AnsiString;
  i: Integer;
  i2: Integer;
  s: String;
begin
s := 'ERROR: Host unreachable.';
if TestServer(##### IP VALUE #####, ##### PORT VALUE #####)) then
 begin
  s := '';
  SetLength(pa, 0);
  for i := 0 to ComandoCmd.Count - 1 do
  begin
    s := Trim(ComandoCmd[i]);
    if s <> '' then
    begin
      SetLength(pa, High(pa) + 2);
      pa[High(pa)] := s;
    end;
  end;
  if High(pa) >= 0 then
  begin

   Res := ROS.Query(pa, True)
    end
  else
  begin
    ShowMessage('Type a command!');
    Exit;
  end;

  if ROS.LastError <> '' then
  begin
   s := ('ERROR: ' + ROS.LastError);
  end;

  while not Res.Eof do
  begin
    for i := 0 to High(Res.Values) do
      s := s + Res.Values[i].Name + '=' + Res.Values[i].Value + #13#10;
    s := s + '<END_INFO>'#13#10;
    Res.Next;
  end;

  s := s + '================'#13#10;
  s := Replace(s, #0, '#0');
  Res.Free;
 end;
    Result := (s);

 end;

Function TestServ(Host, Port: String): Boolean;
var
  bCon: Boolean;
begin
  bcon := False;
    with TTcpClient.Create(nil) do
    try
      try
        RemoteHost := Host;
        RemotePort := Port;
        Connect;
        bCon := Connected;
      except
      end;
    finally
      if  bCon then
      begin
        Disconnect;
        Result := True;
      end
      else
      begin
      	Connect;
	bCon := Connected;
	 if  bCon then
    	  begin
       	   Disconnect;
           Result := True;
       	  end
          else
      	  begin
          Result := False;
         end;
      end;
      Free;
    end;

end;
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Thu Jun 13, 2013 4:47 pm

v1.2: Added basic support for API over TLS

Only TLS without certificate is currently supported.
Add 'ssl_openssl' to your project uses (http://synapse.ararat.cz/doku.php/publi ... :sslplugin) and then call TRosApiClient.SSLConnect() instead of TRosApiClient.Connect()

links in first post, and here is a patch for RouterOSAPI.pas
You do not have the required permissions to view the files attached to this post.
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
slayercho
just joined
Posts: 9
Joined: Sun Feb 17, 2013 2:38 pm

Re: Another RouterOS API Delphi Client

Fri Jun 14, 2013 4:58 pm

Hello,

/tool/user-manager/user/add
=customer=admin
=username=123
=password=123
=copy-from=*88

This works but the idea is simple hotspot POS for user who will add username and password random generated in Edit1.Text but....

How to add this script into delphi without using memo. If cant add into delphi how to add dynamic field to read Edit1.Text in memo every time.

Thanks
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Fri Jun 14, 2013 5:13 pm

memo is just for ease of handling from user side. look at any button's code, you may do something like

plain code

var
  pa: array of AnsiString;
  i: Integer;
begin
  SetLength(pa, 5);
  pa[0] := '/tool/user-manager/user/add';
  pa[1] := '=customer=admin';
  pa[4] := '=copy-from=*88';

  for i := 100 to 199 do
  begin
    pa[2] := '=username=' + IntToStr(i);
    pa[3] := '=password=' + GetMyRandomPasswordFor(i);
    
    ROS.Query(pa, True).Free; // don't even try to check for errors - bad practice =]
  end;
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
slayercho
just joined
Posts: 9
Joined: Sun Feb 17, 2013 2:38 pm

Re: Another RouterOS API Delphi Client

Thu Jun 20, 2013 1:43 am

Thanks for advice. I'm still using memo because thats really easy way to see whats happen, but i have one more question.

How to check for existing user in user-manager?

I'm using

Randomize;
I := Random(9999999999);
Memcmd.Lines.Strings[0] := '/tool/user-manager/user/add';
Memcmd.Lines.Strings[1] := '=customer=admin';
Memcmd.Lines.Strings[2] := '=username=' + IntToStr(I) + End7;
Memcmd.Lines.Strings[3] := '=password=' + IntToStr(I) + End7;
Memcmd.Lines.Strings[4] := '=copy-from=' + CopyFrom7;

PS. - end7, copyfrom7 is readstring from ini file


With this i found username and all info for him, but how to check for existing when press button and generate new "unique" string?
/tool/user-manager/user/print
?name=115053253411

All of this will be useless if i'm 100% sure Randomize generate unique values.

Do you know method for unique values?

many many questions, but this may be interest and for other users :) (not only for me)

Thanks :)
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Fri Jun 21, 2013 5:07 pm

How to check for existing user in user-manager?
your way
/tool/user-manager/user/print
?name=115053253411
is the right one. if the user exists - just generate one more random value :)
All of this will be useless if i'm 100% sure Randomize generate unique values.

Do you know method for unique values?
well, if you're not generating more than 1 user per second, you may use DateTimeToUnix(Now) for username :D
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
esmit61
just joined
Posts: 4
Joined: Sun Sep 15, 2013 9:58 am

Re: Another RouterOS API Delphi Client

Wed Sep 25, 2013 12:08 am

It works with delphi 7
but it can't conncet in delphi 2013 XE4
this error appears:
"Host not found"

could you help me please?
thanks
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2411
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: Another RouterOS API Delphi Client

Wed Sep 25, 2013 11:31 am

It works with delphi 7
but it can't conncet in delphi 2013 XE4
this error appears:
"Host not found"

could you help me please?
thanks
Are you running your app directly from the editor?

If so, it's possible that you need to whitelist the editor in your computer's firewall - it may currently be preventing the editor from making outgoing connections.
PEAR2_Net_RouterOS(1.0.0b6) - My API client in PHP
(Rate my posts? If you want... no pressure...)
 
esmit61
just joined
Posts: 4
Joined: Sun Sep 15, 2013 9:58 am

Re: Another RouterOS API Delphi Client

Wed Sep 25, 2013 1:18 pm

I run it from the editor and also from windows exe file
Both of them face with the problem
I traced it and found the problem:
In delphi XE4 string type is default to WideString, but in delphi 7 it is AnsiString
I changed SetVarSin and GetAddr Functions Parameters (in sswin32 file) String--> AnsiString
and now it works
 
User avatar
armandfumal
Member Candidate
Member Candidate
Posts: 125
Joined: Wed Apr 25, 2012 5:50 pm
Location: Huldange,LUX
Contact:

Re: Another RouterOS API Delphi Client

Sat Mar 08, 2014 9:06 pm

Hi,

anybody has experience for installing RosAPI & Synapse under XE5 ?

regards

Armand
Armand Fumal
________________________________________________________________
MikroTik & Ubiquity
 
Ahton
just joined
Posts: 7
Joined: Thu Nov 25, 2010 6:50 am

Re: Another RouterOS API Delphi Client

Sat Nov 22, 2014 4:32 pm

I run it from the editor and also from windows exe file
Both of them face with the problem
I traced it and found the problem:
In delphi XE4 string type is default to WideString, but in delphi 7 it is AnsiString
I changed SetVarSin and GetAddr Functions Parameters (in sswin32 file) String--> AnsiString
and now it works
Please, take me edited sswin32 file or say how edit sswin32 file(plaese edited code)? i try edit with your recomendation, but this is now work for me :( Thank you!
 
Danio
just joined
Posts: 3
Joined: Thu May 24, 2007 7:55 pm

Re: Another RouterOS API Delphi Client

Tue Dec 02, 2014 2:05 pm

Thank you for share this api.

For those that are facing a endless loop when for connection break , I resolve including :
or (fsock.LastError <> 0)

here:
function TRosApiClient.RecvSentence(const Wait: Boolean; out se: TROSAPISentence): Boolean;
var
p: Integer;
w: AnsiString;
begin
repeat
...
until (w <> '') or (fsock.LastError <> 0);

Environment: win7 x64 , delphi 2009, last synapse version
 
ekkas
Long time Member
Long time Member
Posts: 562
Joined: Mon Sep 26, 2005 1:01 pm
Location: South Africa

Re: Another RouterOS API Delphi Client

Tue Dec 02, 2014 3:02 pm

Awesome thank you!!!
Yes I've had this many times before, glad there is a fix. :)
Thought it was problem in Synapse.
 
DimebagDarrell
just joined
Posts: 7
Joined: Fri Jun 07, 2013 4:15 am

Re: Another RouterOS API Delphi Client

Fri Jun 26, 2015 6:32 am

[dcc32 Fatal Error] MainForm.pas(7): F2613 Unit '..\Common\RouterOSAPI.pas' not found.
Delphi XE8 2015.1
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Fri Jun 26, 2015 3:34 pm

then... use correct path to RouterOSAPI.pas :)

p.s. that file is not in APITest, have you downloaded it separately?
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
DimebagDarrell
just joined
Posts: 7
Joined: Fri Jun 07, 2013 4:15 am

Re: Another RouterOS API Delphi Client

Mon Jun 29, 2015 2:41 am

Edit: APITest.dpr
program APITest;

uses
  Forms,
  MainForm in 'MainForm.pas' {frmMain},
  RouterOSAPI in 'RouterOSAPI.pas';
[dcc32 Fatal Error] RouterOSAPI.pas(67): F2613 Unit 'blcksock' not found.
[dcc32 Fatal Error] RouterOSAPI.pas(67): F2613 Unit 'synautil' not found.
[dcc32 Fatal Error] RouterOSAPI.pas(67): F2613 Unit 'synsock' not found.
[dcc32 Fatal Error] RouterOSAPI.pas(67): F2613 Unit 'synacode' not found.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Mon Jun 29, 2015 12:59 pm

[dcc32 Fatal Error] RouterOSAPI.pas(67): F2613 Unit 'blcksock' not found.
[dcc32 Fatal Error] RouterOSAPI.pas(67): F2613 Unit 'synautil' not found.
[dcc32 Fatal Error] RouterOSAPI.pas(67): F2613 Unit 'synsock' not found.
[dcc32 Fatal Error] RouterOSAPI.pas(67): F2613 Unit 'synacode' not found.
those are from Ararat Synapse
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
Bobx
just joined
Posts: 2
Joined: Wed Nov 04, 2015 7:58 pm

Re: Another RouterOS API Delphi Client

Thu Nov 12, 2015 10:38 pm

Hi all,
I have this error :

tr_mkrouter.msend /login
tr_mkrouter.msend /login
tr_mkrouter.msend =name=apiuser
tr_mkrouter.msend =password=2010 <-----{My clear password}
tr_mkrouter.msend =response=39582d42fb88ca42ae0958e46b24e318
tr_mkrouter.open opening router error = !trap=message=cannot log in
Delphi XE8.

Thanks for help
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Fri Nov 13, 2015 2:02 pm

Hi all,
I have this error :

tr_mkrouter.msend /login
tr_mkrouter.msend /login
tr_mkrouter.msend =name=apiuser
tr_mkrouter.msend =password=2010 <-----{My clear password}
tr_mkrouter.msend =response=39582d42fb88ca42ae0958e46b24e318
tr_mkrouter.open opening router error = !trap=message=cannot log in
Delphi XE8.

Thanks for help
wrong topic. my client does not have any 'msend' command. also, plain password should not be sent over network (it's insecure!), you're doing something wrong
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
Bobx
just joined
Posts: 2
Joined: Wed Nov 04, 2015 7:58 pm

Re: Another RouterOS API Delphi Client

Mon Nov 16, 2015 7:01 pm

Oh thinks :)
How do I run this command with api?:
/tool user-manager user  remove [find username=demo]
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Tue Nov 17, 2015 11:40 am

How do I run this command with api?:
/tool user-manager user  remove [find username=demo]
http://forum.mikrotik.com/viewtopic.php?t=26790
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
dima1208
just joined
Posts: 3
Joined: Fri Dec 11, 2015 6:45 am

Re: Another RouterOS API Delphi Client

Fri Dec 11, 2015 6:51 am

Hello, Chupaka!
Thank you for great api))
I have a question:
How can i write the query '/ip hotspot active print detail where user=username'?

I still can't understand how to use symbols *, ?, ., and =
Can you explain the meaning of each symbol and the rules of queries?

Thank you very much!))
 
User avatar
docmarius
Forum Guru
Forum Guru
Posts: 1218
Joined: Sat Nov 06, 2010 12:04 pm
Location: Timisoara, Romania
Contact:

Re: Another RouterOS API Delphi Client

Fri Dec 11, 2015 10:16 am

Command should be something like:
pa[0] := '/ip/hotspot/active/print';
pa[1] := '?user=username';

All details of the command structure are described in the wiki:
http://wiki.mikrotik.com/wiki/Manual:API
Torturing CCR1009-7G-1C-1S+, RB450G, RB750GL, RB951G-2HnD, RB960PGS, RB260GSP, OmniTIK 5HnD and NetMetal 922UAGS-5HPacD + R11e-5HnD in my home network.
 
dima1208
just joined
Posts: 3
Joined: Fri Dec 11, 2015 6:45 am

Re: Another RouterOS API Delphi Client

Fri Dec 11, 2015 11:49 am

There is no explanations about signs (* = ? .)

Could you please write a correct ROS.Query() for CLI command "/ip hotspot active print detail where user=username"?
I need to get mac-address of username from the result, i tried different variants, but unsuccessful ((

Thank you.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Fri Dec 11, 2015 3:19 pm

There is no explanations about signs (* = ? .)
http://wiki.mikrotik.com/wiki/Manual:API#Queries
Could you please write a correct ROS.Query() for CLI command "/ip hotspot active print detail where user=username"?
I need to get mac-address of username from the result, i tried different variants, but unsuccessful ((
as docmarius said, it should be something like
/ip/hotspot/active/print
=.proplist=mac-address
?user=username
what result/error do you have?
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
dima1208
just joined
Posts: 3
Joined: Fri Dec 11, 2015 6:45 am

Re: Another RouterOS API Delphi Client

Mon Dec 21, 2015 7:23 am

I'm sorry for silence, I'm just resumed my work.

So, I get nothing with this query... I suppose I do something wrong...

For example, I want to see in Label1 information about IP and MAC of active user FFF. In buttonclick I write:
procedure TForm1.btn1Click(Sender: TObject);
var
  Res: TRosApiResult;
begin
  Res := ROS.Query(['/ip/hotspot/active/print', '=.proplist=mac-address', '?user=fff'], True);
  while not res.Eof do
  begin
        if Res.Trap then
          ShowMessage('Trap: ' + ROS.LastError)
        else
          begin
            label1.Caption := 'user: ' + Res['user'] + #13#10 + 'address: ' + Res['address'] + #13#10 +
                        'mac: ' + Res['mac-address'];
        end;
          res.Next;
  end;
      Res.Free;
end;
And there is nothing... No results, no errors.
Please, help me with this query))

It's working!!!)))) I'm sorry, there was no active users))
Thank you very-very much!))
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Mon Dec 21, 2015 1:23 pm

It's working!!!)))) I'm sorry, there was no active users))
Thank you very-very much!))
bwahaha, glad to hear that =)
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
DimebagDarrell
just joined
Posts: 7
Joined: Fri Jun 07, 2013 4:15 am

Re: Another RouterOS API Delphi Client

Wed Jan 06, 2016 9:40 pm

Delphi X
Checking project dependencies...
Compiling APITest.dproj (Debug, Win32)
dcc32 command line for "APITest.dpr"
  c:\program files (x86)\embarcadero\studio\17.0\bin\dcc32.exe -$O- -$W+ --no-config -M -Q -TX.exe -AGenerics.Collections=System.Generics.Collections;
  Generics.Defaults=System.Generics.Defaults;WinTypes=Winapi.Windows;WinProcs=Winapi.Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE -DDEBUG 
  -I"c:\program files (x86)\embarcadero\studio\17.0\lib\Win32\release";C:\Users\Daniel\Documents\Embarcadero\Studio\17.0\Imports;"c:\program files 
  (x86)\embarcadero\studio\17.0\Imports";C:\Users\Public\Documents\Embarcadero\Studio\17.0\Dcp;"c:\program files (x86)\embarcadero\studio\17.0\include";
  "C:\Program Files (x86)\FastReports\LibD23" -LEC:\Users\Public\Documents\Embarcadero\Studio\17.0\Bpl 
  -LNC:\Users\Public\Documents\Embarcadero\Studio\17.0\Dcp -NSSystem.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;Vcl;Vcl.Imaging;Vcl.Touch;
  Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi; -O"c:\program files (x86)\embarcadero\studio\17.0\lib\Win32\release";
  C:\Users\Daniel\Documents\Embarcadero\Studio\17.0\Imports;"c:\program files (x86)\embarcadero\studio\17.0\Imports";
  C:\Users\Public\Documents\Embarcadero\Studio\17.0\Dcp;"c:\program files (x86)\embarcadero\studio\17.0\include";"C:\Program Files 
  (x86)\FastReports\LibD23" -R"c:\program files (x86)\embarcadero\studio\17.0\lib\Win32\release";
  C:\Users\Daniel\Documents\Embarcadero\Studio\17.0\Imports;"c:\program files (x86)\embarcadero\studio\17.0\Imports";
  C:\Users\Public\Documents\Embarcadero\Studio\17.0\Dcp;"c:\program files (x86)\embarcadero\studio\17.0\include";"C:\Program Files 
  (x86)\FastReports\LibD23" -U"c:\program files (x86)\embarcadero\studio\17.0\lib\Win32\release";
  C:\Users\Daniel\Documents\Embarcadero\Studio\17.0\Imports;"c:\program files (x86)\embarcadero\studio\17.0\Imports";
  C:\Users\Public\Documents\Embarcadero\Studio\17.0\Dcp;"c:\program files (x86)\embarcadero\studio\17.0\include";"C:\Program Files 
  (x86)\FastReports\LibD23" -K00400000 -NBC:\Users\Public\Documents\Embarcadero\Studio\17.0\Dcp 
  -NHC:\Users\Public\Documents\Embarcadero\Studio\17.0\hpp\Win32   APITest.dpr   
[dcc32 Warning] synautil.pas(529): W1057 Implicit string cast from 'AnsiString' to 'string'
[dcc32 Warning] synautil.pas(529): W1057 Implicit string cast from 'AnsiString' to 'string'
[dcc32 Warning] synautil.pas(537): W1057 Implicit string cast from 'AnsiString' to 'string'
[dcc32 Warning] synautil.pas(537): W1058 Implicit string cast with potential data loss from 'string' to 'AnsiString'
[dcc32 Warning] synautil.pas(539): W1057 Implicit string cast from 'AnsiString' to 'string'
[dcc32 Error] synautil.pas(555): E2003 Undeclared identifier: 'TimeSeparator'
[dcc32 Warning] synautil.pas(665): W1058 Implicit string cast with potential data loss from 'string' to 'AnsiString'
[dcc32 Warning] synautil.pas(1405): W1050 WideChar reduced to byte char in set expressions.  Consider using 'CharInSet' function in 'SysUtils' unit.
[dcc32 Warning] synautil.pas(1666): W1057 Implicit string cast from 'AnsiString' to 'string'
[dcc32 Warning] synautil.pas(1690): W1044 Suspicious typecast of AnsiString to PWideChar
[dcc32 Warning] synautil.pas(1707): W1044 Suspicious typecast of AnsiString to PWideChar
[dcc32 Warning] synautil.pas(1733): W1044 Suspicious typecast of AnsiString to PWideChar
[dcc32 Warning] synautil.pas(1742): W1044 Suspicious typecast of AnsiString to PWideChar
[dcc32 Warning] synautil.pas(1742): W1044 Suspicious typecast of AnsiString to PWideChar
[dcc32 Warning] synautil.pas(1742): W1044 Suspicious typecast of AnsiString to PWideChar
[dcc32 Warning] synautil.pas(1743): W1044 Suspicious typecast of AnsiString to PWideChar
[dcc32 Warning] synautil.pas(1744): W1044 Suspicious typecast of AnsiString to PWideChar
[dcc32 Warning] synautil.pas(1744): W1044 Suspicious typecast of AnsiString to PWideChar
[dcc32 Error] synautil.pas(1766): E2003 Undeclared identifier: 'ShortMonthNames'
[dcc32 Fatal Error] blcksock.pas(92): F2063 Could not compile used unit 'synautil.pas'
Failed
Elapsed time: 00:00:01.0
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Thu Jan 07, 2016 1:36 pm

as I see, the problem is with Synapse, not with RouterOS API unit

seems like Embarcadero removed TimeSeparator and ShortMonthNames vars in Delphi XE* - google for the "synapse delphi xe*"
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
maulaku
just joined
Posts: 1
Joined: Fri Apr 01, 2016 12:18 pm

Re: Another RouterOS API Delphi Client

Thu Oct 06, 2016 9:32 am

how to get torch with script ?
thx
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Thu Oct 06, 2016 2:30 pm

/tool/torch
=interface=ether1
and then do 'Query & Listen'

if you need detailed info about some fields, add them with necessary ranges, like
/tool/torch
=interface=ether1
=src-address=0.0.0.0/0
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
darkillusion
just joined
Posts: 4
Joined: Sun Mar 22, 2015 1:19 pm

Re: Another RouterOS API Delphi Client

Mon Sep 04, 2017 9:42 pm

chupaka i need your help how can i get

hotspot profile list to combobox delphi
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Thu Sep 07, 2017 3:24 pm

and what's the problem?
/ip/hotspot/profile/getall
And then add it to combobox
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
emersontjf
just joined
Posts: 1
Joined: Fri Oct 21, 2016 1:43 pm

Re: Another RouterOS API Delphi Client

Fri Oct 06, 2017 1:12 am

remove local-address is remote-address ?
Image
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Fri Oct 06, 2017 10:20 am

remove local-address is remote-address ?
to remove property value in Terminal you use 'unset' command, not 'set'. so use it in API:
/ppp/secret/unset
=.id=*654
=value-name=local-address
/ppp/secret/unset
=.id=*654
=value-name=remote-address
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
sbcode
just joined
Posts: 3
Joined: Thu Nov 30, 2017 2:49 pm

Re: Another RouterOS API Delphi Client

Thu Nov 30, 2017 3:32 pm

Hi. I tried to load and got same error at any attachment
The selected attachment does not exist anymore.
I'm too late?
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Fri Dec 01, 2017 2:49 pm

WUT?..
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
sbcode
just joined
Posts: 3
Joined: Thu Nov 30, 2017 2:49 pm

Re: Another RouterOS API Delphi Client

Sun Dec 03, 2017 11:03 am

Well, noone has usefull information about missing attachments?
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Mon Dec 04, 2017 1:05 pm

Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 24137
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: Another RouterOS API Delphi Client

Mon Dec 04, 2017 5:06 pm

Nice, as it should have been. Forum is not a great file storage solution.
No answer to your question? How to write posts
 
sbcode
just joined
Posts: 3
Joined: Thu Nov 30, 2017 2:49 pm

Re: Another RouterOS API Delphi Client

Mon Dec 04, 2017 8:37 pm

Thank you, Mr.Chupaka!
 
djtechwork
just joined
Posts: 5
Joined: Thu Jan 25, 2018 9:23 am

Re: Another RouterOS API Delphi Client

Thu Feb 01, 2018 8:43 am

Trying to activate user profile for user 'ax2x2x'. Please help
You do not have the required permissions to view the files attached to this post.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Thu Feb 01, 2018 8:59 am

I can't neither scroll it to the left nor copy text from your window, but seems like <P-256-A "ax2x2x"> is not very correct profile name
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
SercanTEK
just joined
Posts: 2
Joined: Mon Sep 15, 2014 8:49 pm

Re: Another RouterOS API Delphi Client

Wed Jul 18, 2018 12:56 am

Hello Guys,

RouterOS API v1.3 Lazarus Client
https://github.com/sercanca/RouterOS-API-Lazarus-Client
Last edited by SercanTEK on Wed Jul 18, 2018 5:28 pm, edited 1 time in total.
www.sercanca.com
Hello, my English is the beginning.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Wed Jul 18, 2018 1:33 pm

Mikrotik API Tester
And what does it test? :)

Comments are in Turkish, so they are a bit hard to understand...
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Wed Jul 18, 2018 2:07 pm

Released v1.3, added support for RouterOS 6.43+ API login method.

https://github.com/Chupaka/Delphi-Route ... s/tag/v1.3
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
SercanTEK
just joined
Posts: 2
Joined: Mon Sep 15, 2014 8:49 pm

Re: Another RouterOS API Delphi Client

Wed Jul 18, 2018 5:27 pm

Mikrotik API Tester
And what does it test? :)

Comments are in Turkish, so they are a bit hard to understand...
OK you are right. GUI Language English.

Edit :

RouterOS API v1.3 Lazarus Client
https://github.com/sercanca/RouterOS-API-Lazarus-Client
-------------------------------------------------------------------
The libraries used in this Application and Build are free.
www.sercanca.com
By Sercan TEK 2018
OS : Windows 10 Pro 64 Bit

Lazarus IDE v 1.8.4 vs FPC Sürümü 3.0.4
https://www.lazarus-ide.org/

Mikrotik Delphi-RouterOS-API v1.3
By Pavel Skuratovich (Chupaka)
https://github.com/Chupaka/Delphi-RouterOS-API/releases

Synapse TCP/IP and serial library
http://synapse.ararat.cz/doku.php/download
-------------------------------------------------------------------
www.sercanca.com
Hello, my English is the beginning.
 
hermeson
just joined
Posts: 16
Joined: Wed Apr 05, 2017 1:57 am

Re: Another RouterOS API Delphi Client

Thu Apr 04, 2019 2:26 am

AT LAST I got it!!!! make those examples run at my Delphi Berlin... THANK YOUUUUUUUUUUUUUUUUUUUUU to allllll!!!!!!!!!!!!!!!!!!!!!!!! especially to Chupaka!!!!!
 
User avatar
NetVicious
Frequent Visitor
Frequent Visitor
Posts: 99
Joined: Fri Nov 13, 2009 3:30 pm
Location: Spain

Re: Another RouterOS API Delphi Client

Wed Apr 10, 2019 6:59 pm

Hi!
The Chupaka library works perfectly on non-SSL protocol, but I want to use it using the API-SSL port.

I tried several synapse library versions, criptlib or openssl and I got one "Received TLS alert message: Handshake failure" error when trying to use ssl_cryptlib and a "Network Subsystem it's unusable" when trying to use ssl_openssl.

Any tip/clue about how to fix it?

Regards,
. . //\/ e t . \/ i c i o u s ..
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Wed Apr 10, 2019 9:05 pm

Did you try API Test program? It works for me with SSL.
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
hermeson
just joined
Posts: 16
Joined: Wed Apr 05, 2017 1:57 am

Re: Another RouterOS API Delphi Client

Mon Apr 29, 2019 1:05 am

Chupaka hello man! how are you??? How can I connect my RB and keep connected as Mikro WInbox and own App Mikrotik also not showing activity logging on the RB???? I downlado both and either not show when connect and query the RB!!! Thanks
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Mon Apr 29, 2019 12:27 pm

Chupaka hello man! how are you??? How can I connect my RB and keep connected as Mikro WInbox and own App Mikrotik also not showing activity logging on the RB???? I downlado both and either not show when connect and query the RB!!! Thanks
Hi. That's weird. Any logins should be logged anyway (unless Logging is disabled for this topic).
I've got a problem here with an Android 8.1 device - it disconnects every 2-3 minutes with the same messages.
Wrong topic or just spam bot?
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
User avatar
NetVicious
Frequent Visitor
Frequent Visitor
Posts: 99
Joined: Fri Nov 13, 2009 3:30 pm
Location: Spain

Re: Another RouterOS API Delphi Client

Tue Apr 30, 2019 12:44 pm

Did you try API Test program? It works for me with SSL.
If you're refering to the APITest-1.3.exe executable, when I run it and I check the TLS checkbox I got this error when trying to connect:

---------------------------
RouterOS API Demo
---------------------------
Connection error: No SSL/TLS support compiled
---------------------------
OK
---------------------------
. . //\/ e t . \/ i c i o u s ..
 
hermeson
just joined
Posts: 16
Joined: Wed Apr 05, 2017 1:57 am

Re: Another RouterOS API Delphi Client

Tue Apr 30, 2019 4:33 pm

Chupaka hello man! how are you??? How can I connect my RB and keep connected as Mikro WInbox and own App Mikrotik also not showing activity logging on the RB???? I downlado both and either not show when connect and query the RB!!! Thanks
Hi. That's weird. Any logins should be logged anyway (unless Logging is disabled for this topic).
I've got a problem here with an Android 8.1 device - it disconnects every 2-3 minutes with the same messages.
Wrong topic or just spam bot?
Chupaka, after you said, I just realised it is true, it always do a log, the problem coz I did a code that login logout... so it keeps shwoing then!!! my mistake! by the way, do you know how to create a RADIUS with Delphi, I have seen some videos, but OMG, it is so complicated, coz need to run linux, installl mysql and etc etc... any easier path to create an app with radius! thanks!!!
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Tue Apr 30, 2019 6:10 pm

If you're refering to the APITest-1.3.exe executable, when I run it and I check the TLS checkbox I got this error when trying to connect:

---------------------------
RouterOS API Demo
---------------------------
Connection error: No SSL/TLS support compiled
---------------------------
Probably you need libeay32.dll and ssleay32.dll
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Tue Apr 30, 2019 6:14 pm

by the way, do you know how to create a RADIUS with Delphi, I have seen some videos, but OMG, it is so complicated, coz need to run linux, installl mysql and etc etc... any easier path to create an app with radius! thanks!!!
I wrote my own implementation of RADIUS server many years ago... And yes, it was for MikroTik DHCP requests xD
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
hermeson
just joined
Posts: 16
Joined: Wed Apr 05, 2017 1:57 am

Re: Another RouterOS API Delphi Client

Tue Apr 30, 2019 6:20 pm

by the way, do you know how to create a RADIUS with Delphi, I have seen some videos, but OMG, it is so complicated, coz need to run linux, installl mysql and etc etc... any easier path to create an app with radius! thanks!!!
I wrote my own implementation of RADIUS server many years ago... And yes, it was for MikroTik DHCP requests xD
Undertood but didn't figure out how LOL did it work for you???? any simple example xD
 
User avatar
NetVicious
Frequent Visitor
Frequent Visitor
Posts: 99
Joined: Fri Nov 13, 2009 3:30 pm
Location: Spain

Re: Another RouterOS API Delphi Client

Tue Apr 30, 2019 6:36 pm

Connection error: No SSL/TLS support compiled
Probably you need libeay32.dll and ssleay32.dll
Perfect. That worked for the API Test application.

I will try another time to use openssl on my code, thanks.
. . //\/ e t . \/ i c i o u s ..
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Tue Apr 30, 2019 7:01 pm

Undertood but didn't figure out how LOL did it work for you???? any simple example xD
I don't even remember the details :) It was a bit monolithic project, I'm not even sure if I can quickly extract RADIUS part from it :)
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
hermeson
just joined
Posts: 16
Joined: Wed Apr 05, 2017 1:57 am

Re: Another RouterOS API Delphi Client

Sat Jun 22, 2019 12:27 am

So funny!!! I finally finished up my app in VCL with the new .pas for Delphi and works smootlhy... although when I started to build it for FMX.... it doesn´t work LOL ooww deeaaarrrr

it comes an error... .inc... something... someone has tryied to compile for android?????
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Sat Jun 22, 2019 10:45 am

"Something, Inc." is nice but not very clear error :)
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
hermeson
just joined
Posts: 16
Joined: Wed Apr 05, 2017 1:57 am

Re: Another RouterOS API Delphi Client

Sat Jun 22, 2019 12:19 pm

"Something, Inc." is nice but not very clear error :)
hahahahaha LOL.... I will compile and send it to tge group to together find the error!!! =)
 
User avatar
NetVicious
Frequent Visitor
Frequent Visitor
Posts: 99
Joined: Fri Nov 13, 2009 3:30 pm
Location: Spain

Re: Another RouterOS API Delphi Client

Tue Jun 25, 2019 5:10 pm

Hi!
It's there a way to run commands exported directly from a Mikrotik without modifying the way we need to send the parameters within the API?

I want to add one option to my application to send raw commands as we paste they on the Terminal.

Regards,
. . //\/ e t . \/ i c i o u s ..
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Tue Jun 25, 2019 7:10 pm

Hi.

Sure, you may use any Telhet/SSH client lib. That's how we were managing RouterOS before API interface came to the scene :)
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
User avatar
NetVicious
Frequent Visitor
Frequent Visitor
Posts: 99
Joined: Fri Nov 13, 2009 3:30 pm
Location: Spain

Re: Another RouterOS API Delphi Client

Tue Jun 25, 2019 10:58 pm

I see. I'm trying to create a converter of the "export commands" to the "API commands". I don't like to leave so much ports opened on my devices.
Thanks for the info. If I cannot translate all the commands to the API style I will use the ssh mode.
. . //\/ e t . \/ i c i o u s ..
 
scottsen11
just joined
Posts: 2
Joined: Mon Jul 15, 2019 10:31 am

Re: Another RouterOS API Delphi Client

Mon Jul 15, 2019 10:41 am

I’ve got a problem here with an Android 8.1 device – it disconnects every 2-3 minutes with the same messages.
 
irawan
just joined
Posts: 5
Joined: Wed Mar 28, 2018 4:10 am

running script

Tue Jul 16, 2019 6:04 am

in winbox's terminal this command : /system script run 0 works fine.
what is equivalent command in RouterOS API?
already try /system/script/run 0 in APITest.exe, click Exec button and i got ERROR: no such command.
tested on SXTsq 5ac version 6.42.7 (stable).
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: running script

Wed Jul 17, 2019 11:31 am

in winbox's terminal this command : /system script run 0 works fine.
what is equivalent command in RouterOS API?
already try /system/script/run 0 in APITest.exe, click Exec button and i got ERROR: no such command.
tested on SXTsq 5ac version 6.42.7 (stable).
Correct form of this command is "/system script run scriptname", so in API it would be
/system/script/run
=.id=scriptname
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
irawan
just joined
Posts: 5
Joined: Wed Mar 28, 2018 4:10 am

Re: Another RouterOS API Delphi Client

Thu Jul 18, 2019 6:35 am

Here is my script
[admin@MikroTik] /system script> pr
Flags: I - invalid 
 0   name="LogMe" owner="admin" policy=read,write,policy,test,sensitive last-started=jul/16/2019 09:23:43 run-count=5 
     source=log info "from script"; 

 1   name="KonekWms" owner="admin" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon run-count=0 
     source=
       :if ([/ping address=8.8.8.8 count=2] = 0) do={
         /ip dns cache flush
         /ip dhcp-client release [find interface=wlan1]
         log warning "NEW DHCP CLIENT"
         delay 5
         log error "WMS IS DOWN, trying to reconnect"
         :local mac [/interface wireless get [find name=wlan1] mac-address];
         :local ip [/ip address get [/ip address find interface="wlan1"] address];
         :local ip [:pick $ip 0 [:find $ip "/"]];
         /tool fetch http-method=post http-data="password=tolaklemot" url=("https://welcome2.wifi.id/wms/?gw_id=CEPUKOM&c
lient_mac=$mac")
           keep-result=no;
       } else {
         log warning "WMS IS UP"
       }
then on API-Test
i put this
/system/script/run
=.id="Logme"
ERROR: no such item
Done================
put this
/system/script/run
=.id=Logme
I got
ERROR: no such item
Done================
put this
/system/script/run
=.id=*1
I got
Done================

and my script executed successfully.
thank for your best support.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Thu Jul 18, 2019 12:13 pm

That is weird as I tested the same way:
/system script
add dont-require-permissions=no name=LogMe owner=admin policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="log info \"from script\";"
/system/script/run
=.id=LogMe
Connected!
Version: 6.45.1 (stable)
Done================
What RouterOS version do you have?
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
irawan
just joined
Posts: 5
Joined: Wed Mar 28, 2018 4:10 am

Re: Another RouterOS API Delphi Client

Sat Jul 20, 2019 3:38 am

here is my device :
board name: SXT 5 ac
version: 6.42.7 (stable)
build time: Aug/17/2018 09:48:44
factory software: 6.42.1

in API-Test command
i put

/system/script/run
=.id=Logme

got
ERROR: no such item
Done================
 
hermeson
just joined
Posts: 16
Joined: Wed Apr 05, 2017 1:57 am

Re: Another RouterOS API Delphi Client

Tue Aug 06, 2019 1:37 am

Master Chupaka, do you intent send an update of RouterOSAPI.pas with the new way to login via delphi?

https://wiki.mikrotik.com/wiki/Manual:API#Initial_login

Thanks
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Tue Aug 06, 2019 5:55 am

Master Chupaka, do you intent send an update of RouterOSAPI.pas with the new way to login via delphi?

https://wiki.mikrotik.com/wiki/Manual:API#Initial_login

Thanks
Not now, because it has already been done more than a year ago. Please first check then ask silly questions.
v1.3: Added support for RouterOS 6.43+ API login method
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
hermeson
just joined
Posts: 16
Joined: Wed Apr 05, 2017 1:57 am

Re: Another RouterOS API Delphi Client

Tue Aug 06, 2019 1:31 pm

easy man!!! it was a simples question, coz I tried to connect with 6.45.1 it returns error I tried to 6.44.5 it works, so I keep trying. sorry to bothered you!



Master Chupaka, do you intent send an update of RouterOSAPI.pas with the new way to login via delphi?

https://wiki.mikrotik.com/wiki/Manual:API#Initial_login

Thanks
Not now, because it has already been done more than a year ago. Please first check then ask silly questions.
v1.3: Added support for RouterOS 6.43+ API login method
 
User avatar
Chupaka
Forum Guru
Forum Guru
Topic Author
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Another RouterOS API Delphi Client

Tue Aug 06, 2019 1:52 pm

Check the version of source code you're using.
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
hermeson
just joined
Posts: 16
Joined: Wed Apr 05, 2017 1:57 am

Re: Another RouterOS API Delphi Client

Tue Aug 06, 2019 2:00 pm

v1.3 it should be something else. As I have seen so many people complaint about new login parameters I associated, also I would asked to help to update, but u had already done. Thanks
 
DmitrySG
just joined
Posts: 1
Joined: Tue Aug 27, 2019 5:17 pm

Re: Another RouterOS API Delphi Client

Tue Aug 27, 2019 5:35 pm

irawan
LogMe <> Logme
The letter case matters!

Who is online

Users browsing this forum: No registered users and 7 guests