Problem with the execute() function in 4b2

I am trying to write a probe that uses the execute function and cannot get it to work. My Dude is version 4 Beta 2 running on a Windows 2003 server. I initially wrote the probe I wanted but could not get it to give me any results. I have been fault finding as recommended in other places in this forum by adding the probe code to a device label to be able to see the results.

I have gradually reduced the complexity of the probe to a point where it no longer relates to what I am trying to do - so please don’t ask why I am trying to write such a stupid probe :smiley:

I think I have now arrived at a point where it is beyond doubt that it is the execute function that doesn’t work properly, but I will be happy to be corrected on that if someone can point out the error of what I have done.

Here is the code that I have in my device label:

[array_element(execute("cmd.exe","echo test","c:\windows\system32"),1)]

I would expect “test” to appear on my device label but nothing appears. If I change the code to:

[array_element(execute("cmd.exe","echo test","c:\windows\system32"),0)]

Then the device label shows “-1”, which to my understanding of the way that the execute function is supposed to work indicates that it has returned an error.

I have also tried “escaping” the file path as suggested elsewhere in the forum (c:\windows\system32) to no avail.

Has anyone else had success in using the execute() function?

I have seen some weirdness with what it will execute like it would not execute a “test.cmd” file(but that could have been my trouble).

Make a bat file; For simplicity put it in the root of drive c: on the dude server.
test.bat
@echo off
echo %1

[array_element(execute(“test.bat”,“stuff”,“c:\”),1)]
Place that on a device label, and you should see stuff on your label.
test (2).png

Yes you must escape backslashes.

I find it interesting that there is a carriage return after the 2nd array item.

Thanks lebowski - I am happy to be shown that the execute function does work. I have tested your example and confirm that I am getting the expected result now. Now - on to the probe I really want…

Many thanks. :smiley: