NetXMS Support Forum

English Support => General Support => Topic started by: gkaudewitz on August 29, 2015, 03:30:27 PM

Title: Request user input from nxsl
Post by: gkaudewitz on August 29, 2015, 03:30:27 PM
Hello together,

is there a possibility to request some userinput from a script? This input from a mask the user can fill within the GUI should be attached for example to the current node or container as CustomAttributes.

Best regards

Georg
Title: Re: Request user input from nxsl
Post by: Victor Kirhenshtein on August 29, 2015, 11:02:04 PM
Hi,

no, it's not possible. However, it is possible to create object tools with input fields - depending on what you are trying to achieve it may be good alternative.

Best regards,
Victor
Title: Re: Request user input from nxsl
Post by: gkaudewitz on August 30, 2015, 11:08:35 PM
Hello Victor,

thank's for the tip! But how can I pass the values of the Input Fields to a servercommand that will call nxscript for inserting the values of the Input Fields as Custom Attributes?
The node  identified by %n can be passed in the commandline  in Object Tools.
Best regards
Georg
Title: Re: Request user input from nxsl
Post by: tomaskir on August 30, 2015, 11:32:10 PM
Create a normal server command Object Tools, and as command, use this:
/root/some/script.sh %a %U %(foo) %(bar)

Where foo and bar are from your input fields.
(you still need to configure the input fields in their configuration)
Title: Re: Request user input from nxsl
Post by: gkaudewitz on August 31, 2015, 10:41:08 AM
Thaks for fast answering my questions to all of you.

I tried all other combinations of brackets and % but not this one...

One more question now: I've tested a script on an other system running on 2.0-RC1 and got a window requesting values for the parmeters. My production system still is running on 1.1.17 there I get no window requesting the values. Is there a difference between 2.0 and 1.1.17 or is there a Problem with my production Environment (Java on the Client or something else..)
Title: Re: Request user input from nxsl
Post by: gkaudewitz on August 31, 2015, 10:50:22 AM
Sorry I just read that inputfields for object Tools have been implemented with 2.0-RC1....
Title: Re: Request user input from nxsl
Post by: gkaudewitz on August 31, 2015, 11:40:58 PM
It's confusing....

runnig the following script with /data/netxms/bin/nxscript /data/scripts/first.nxsl 124 ddd dddd I always get the same error:

NetXMS Scripting Host  Version 2.0-RC1
Copyright (c) 2005-2015 Victor Kirhenshtein

Error 11 in line 4: Function not found


An object with ID 124 exists in my testdatabase. There is no differencs wether I run the script from objecttools or from Linux commandline.

sub main()
{

obj = FindObject(null,$1);
if (obj == null)
   { println "Object not found Id:" . $1;
     return;
   };
SetCustomAttribute(obj,"Bau",$2);
SetCustomAttribute(obj,"Etage",$3);
SetCustomAttribute(obj,"Raum",$4);

//println "Hello World " . $1 . " " . $2 . " " . $3 . " " . $4 . " " . $5;
}


Is it necessary to set some path or lib-variables?

I'm using version 2.0-RC1(8035)

Title: Re: Request user input from nxsl
Post by: tomaskir on September 01, 2015, 12:32:18 AM

sub main()
{
  obj = FindObject($1);
  if (obj == null)
  {
    println "Object not found Id:" . $1;
    return;
  }

  SetCustomAttribute(obj,"Bau",$2);
  SetCustomAttribute(obj,"Etage",$3);
  SetCustomAttribute(obj,"Raum",$4);

  //println "Hello World " . $1 . " " . $2 . " " . $3 . " " . $4 . " " . $5;
}
Title: Re: Request user input from nxsl
Post by: gkaudewitz on September 01, 2015, 08:56:04 AM
Thank's for the correction concerning the function FindObject. I tried the function FindNodeObject too several times.
But the problem persists.

NetXMS Scripting Host  Version 2.0-RC1
Copyright (c) 2005-2015 Victor Kirhenshtein

Error 11 in line 4: Function not found


Best regards

Georg
Title: Re: Request user input from nxsl
Post by: Victor Kirhenshtein on September 01, 2015, 11:30:02 AM
Hi,

nxscript provides only generic functions, as it is completely independent from server process. You have to run your script within netxmsd, for example using nxadm:


/data/netxms/bin/nxadm -c 'exec /data/scripts/first.nxsl 124 ddd dddd'


and if you need to execute NXSL script as reaction to event, you can simply create your script in script library and use "execute script" action.

Best regards,
Victor
Title: Re: Request user input from nxsl
Post by: gkaudewitz on September 01, 2015, 06:25:15 PM
Hi,

Your advise in mind how to call the nxsl-Script everything worked fine for Nodes!
Trying to execute the same script for a Container within the gui does not work at all.
I inserted a println-statement to the script to see the object-Id that is called, but I don't get any Output for a containerobject.
Executing the script directly from commandline on Linux with an id identifying a Container I will get the expected result for that container.

Best regards

Georg