NetXMS Support Forum

English Support => General Support => Topic started by: Marco Incalcaterra on September 02, 2011, 06:16:50 PM

Title: Parameters with spaces on execute command on management server
Post by: Marco Incalcaterra on September 02, 2011, 06:16:50 PM
Hi,

I wrote a small program to notify some events via the execute command on management server action property, it works properly unless I put parameters inside double quotes. I'll try to better explain with an example:

This command works properly:

c:\\test\\myprg.exe firstpar secondpar thirdpar

This command doesn't work:

c:\\test\\myprg.exe "first par" "second par" "third par"

Is there a way to specify parameters that have spaces (my parameters are strings)?

Best regards,
Marco.
Title: Re: Parameters with spaces on execute command on management server
Post by: Victor Kirhenshtein on September 03, 2011, 08:40:41 PM
Hi!

That's strange. Just checked it on my development server, and commands with parameters enclosed in double quotes works just fine. What server version you are using? Also, can you determine what parameters are passed to your program?

I use the following small test program:


#include <stdio.h>

int main(int argc, char *argv[])
{
FILE *f = fopen("c:\\temp\\s.log","w");
fprintf(f, "p1: %s\n", argv[1]);
fprintf(f, "p2: %s\n", argv[2]);
fprintf(f, "p3: %s\n", argv[3]);
fclose(f);
return 0;
}


and for action with command

c:\\source\\s.exe "first par" "second par" "third par"

got correct output in c:\temp\s.log:


p1: first par
p2: second par
p3: third par


Best regards,
Victor
Title: Re: Parameters with spaces on execute command on management server
Post by: Marco Incalcaterra on September 08, 2011, 06:53:38 PM
Hi Victor,

sorry for the long time reply, bad days... I'm using server version 1.1.3. I prepared an action to send SMS using a small prog I wrote, currently the "command" section is:

"C:\\Program Files\\NetXMS\\SMSTool\\SMSTx.exe" -n smsnumber1 -n smsnumber2 -t WebServerUnreachable-%n(%a)

while the original one (that doesn't work) was:

"C:\\Program Files\\NetXMS\\SMSTool\\SMSTx.exe" -n smsnumber1 -n smsnumber2 -t "Error web server is unreachable: %n (%a)"

Using the above statement I only got "Error" and the part " web server is unreachable: %n (%a)" never arrives to my program. Can be the parser that expand the %n and %a that removes the double quotes before posting it to the program? For now I solved removing the spaces but for the future can be interesting to send more complex texts.

Thank you very much for your help.

Best regards,
Marco.