Re: [Mikrotik] Using a script variable as part of a script command

2010-12-13 Thread Kristian Hoffmann
Note that :execute runs asynchronously, so you can't assume that it will complete before the next line in the script (which is handy sometimes). :parse, does however. Instead of ":execute $cmd;" in your example, you would do... :local pCmd [:parse $cmd] $pCmd; I believe the trailing semicolon i

Re: [Mikrotik] Using a script variable as part of a script command

2010-12-12 Thread Andrew Cox
That, by the way.. makes :execute the 4th undocumented command I've found this week >_< Kind Regards, Andrew Cox AccessPlus - Head Network Administrator Ph: 1300 739 822 (7am - 12 midnight AEST) On 12 December 2010 18:48, Andrew Cox wrote: > Legendary. > > The following works as required: > >

Re: [Mikrotik] Using a script variable as part of a script command

2010-12-12 Thread Andrew Cox
Legendary. The following works as required: *#Set initial entry command* *:set cmd "/ip route add"* * * *#Import current entry (Some entries cannot be entered as blank, must check these beforehand)* * * *:if ([:len $distance] > 0 ) do={:set cmd "$cmd distance=$distance"}* *:if ([:len $dstaddress]

Re: [Mikrotik] Using a script variable as part of a script command

2010-12-11 Thread Butch Evans
On 12/11/2010 10:14 AM, Andrew Cox wrote: *Code:* :if ([:len $bgplocalpref]> 0 ) do={:set bgplocalpref "bgp-local-pref=$bgplocalpref"} /ip route add dst-address=$dstaddress gateway=$gateway $bgplocalpref However this also simply generates an error (I'd expected that it'd just continue on with

Re: [Mikrotik] Using a script variable as part of a script command

2010-12-11 Thread Chupaka
Try with ":execute" command: :local cmd "/ip route add"; if ([:len $bgplocalpref] > 0) do={:set cmd "$cmd bgp-local-pref=$bgplocalpref";} if ([:len $bgpprepend] > 0) do={:set cmd "$cmd bgp-prepend=$bgpprepend";} :execute $cmd; 2010/12/11 Andrew Cox > I've updated the forum post with more i

Re: [Mikrotik] Using a script variable as part of a script command

2010-12-11 Thread Andrew Cox
I've updated the forum post with more information: http://forum.mikrotik.com/viewtopic.php?f=9&t=47393&p=240173#p240173 It would seem that *some* values don't mind being passed a blank variable from within a script, while others

Re: [Mikrotik] Using a script variable as part of a script command

2010-12-11 Thread Andrew Cox
That would work except for the fact we need to check it against more than one value. So to do so I end up having to create an if statement for each assortment of blanks vs non-blanks Eg: Case 1: If bgp-communities=blank & bgp-local-pref=blank & bgp-med=blank & bgp-origin=blank & bgp-prepend=blank

Re: [Mikrotik] Using a script variable as part of a script command

2010-12-11 Thread Scott Reed
if ([:len $bfplocalpref > 0) /ip route add dst-address=$dstaddress gateway=$gateway $bgplocalpref else /ip route add dst-address=$dstaddress gateway=$gateway end if or if ([:len $bfplocalpref> 0) /ip route add dst-address=$dstaddress gateway=$gateway $bgplocalpref if ([:len $bfplocalpref<= 0

[Mikrotik] Using a script variable as part of a script command

2010-12-11 Thread Andrew Cox
Hi guys, Back with another script-related query today [image: :-)] I've got this up as a thread in the forum too if anyone wants to reply there, will be posting whatever solution I come across to help others - http://forum.mikrotik.com/viewtopic.php?f=9&t=47393 Trying to write a section of