Community discussions

MikroTik App
 
User avatar
CyberTod
Long time Member
Long time Member
Topic Author
Posts: 510
Joined: Wed Jan 25, 2012 10:23 am

Parse failed - problem with execute command

Tue May 20, 2014 9:28 am

Hello, I am trying to add a probe to monitor a RRCP switch. There is not an integrated support for that and I am trying to do it with an external execute.
I have set up this function for when there is an error but is doesnt work :

if(array_element(execute("winertlping",device_property("CustomField1")", "Z:\bin",10),2)>0,"","error")

I get a 'parse failed'
the command which I execute is a script which includes this :

/bin/rtlping -c 3 -q $1

I use CustomField1 because I don't find a variable to pass the device's mac address. My CustomField1 has this in it :

52:54:4c:00:00:01@eth1

If I execute the command from shell I get this if there is a connection to the switch :
52:54:4c:00:00:01@eth1 : 0.073 0.010 0.015
And this if no connection :
52:54:4c:00:00:01@eth1 : - - -

So if anyone has any ideas. Is there an error in my function ? Or is it the fact that this is a linux command which I try to execute through wine (it works in 'wine cmd' but the result is echoed in cmd) ?
Is there any other way to do this ?

2nd try : To eliminate the problem of executing a linux command today I'm trying the following :
if(array_element(execute("rtlping.cmd", device_property("CustomField1"), "C:\",30),0)=0,"","error")
and rtlping.cmd contents are :
@echo off
type Z:\var\www\htdocs\rrcp\%1
And I still get 'parse failed'. I don't understand why that is. This should indicate an error in my statement but the example is taken from the wiki and the result from command is 0 if there is a connection and 100 if there is not. As simple as it gets.
 
lebowski
Forum Guru
Forum Guru
Posts: 1619
Joined: Wed Aug 27, 2008 5:17 pm

Re: Parse failed - problem with execute command

Mon Jun 02, 2014 7:40 pm

There is some change in how execute works.. double backslash
http://forum.mikrotik.com/viewtopic.php ... te#p359122
Look at the syntax of these...
 
User avatar
CyberTod
Long time Member
Long time Member
Topic Author
Posts: 510
Joined: Wed Jan 25, 2012 10:23 am

Re: Parse failed - problem with execute command

Tue Jun 03, 2014 10:21 am

The double backlash works. Thank you.
Now this probe works :

if(array_element(execute("rtlping.cmd", device_property("CustomField1"), "C:\\",30),0)=0,"","error")

But it only has a 'type Z:\var\www\htdocs\rrcp\%1' command in it, so I still execute another command in linux's cron to fill those files.
The other statement :

if(array_element(execute("winertlping", device_property("CustomField1"), "Z:\\bin",10),0)=0,"","error")

No longer gives parse failed. But when I use it it says only 'probing' on status and the entire Dude goes unresponsive. I have changed the script to return 0 if service is up and 1 if down. But it is still a linux script executed under wine. This is what happens if i execute through cmd :

Z:\>Z:\bin\winertlping 52:54:4c:00:00:07@eth0
Z:\>0
(cursor blinks, no new line waiting for command)

P.S. So this no longer seems like a Dude problem, more like a Wine problem. But the issue is that there is no native linux version of Dude, so I'm stuck with this :) (and before someone suggests that I use it on windows : there is no 'rtlping' on windows except maybe with cygwin). I will still gladly accept any ideas or workarounds.

Who is online

Users browsing this forum: No registered users and 12 guests