Community discussions

MikroTik App
 
agnostic
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 61
Joined: Fri Mar 21, 2014 8:23 pm

lease-hostname lease script variable not working

Sat Aug 10, 2019 1:43 am

hello i put the following script to dhcp lease scripts according to this manual https://wiki.mikrotik.com/wiki/Manual:IP/DHCP_Server

/tool fetch url=("http://10.10.10.1/add.php?clienthostnam ... easeActMAC")

which is working perfect from server side BUT this weird happens:
at log output window i get mac correctly and as clienthostname i get -hostname which of course is parsed to database as client name and is wrong.
i understand that i must parse variables another way so i try to parse it as follows:

/tool fetch url=("http://10.10.10.1/add.php?clienthostname=" . $lease-hostname . "&mac=" . $leaseActMAC) and it gives me an empty client name but mac address is ok which of course again it parses only mac address on database and leaves hostname empty.
even if i change the order of mac and client name the client name remains empty.

would it be me and the way i use to handle this specific variable or it does not want to give host name?
 
User avatar
sebastia
Forum Guru
Forum Guru
Posts: 1782
Joined: Tue Oct 12, 2010 3:23 am
Location: Antwerp, BE

Re: lease-hostname lease script variable not working

Sat Aug 10, 2019 4:43 am

hey, try $"lease-hostname" instead
 
achmad
just joined
Posts: 2
Joined: Sun Apr 02, 2023 11:54 pm

Re: lease-hostname lease script variable not working

Sun Apr 02, 2023 11:56 pm

try this $[:put [/ip/dhcp-server/lease/get value-name=host-name [find where mac-address=$leaseActMAC]]]
 
achmad
just joined
Posts: 2
Joined: Sun Apr 02, 2023 11:54 pm

Re: lease-hostname lease script variable not working

Sun Apr 02, 2023 11:57 pm

$[:put [/ip/dhcp-server/lease/get value-name=host-name [find where mac-address=$leaseActMAC]]]
 
makrob
just joined
Posts: 4
Joined: Sun Dec 10, 2023 12:44 pm

Re: lease-hostname lease script variable not working

Sun Jun 02, 2024 8:58 pm

hey, try $"lease-hostname" instead
Thanks, this $"lease-hostname" worked for me.