News:

We really need your input in this questionnaire

Main Menu

Request user input from nxsl

Started by gkaudewitz, August 29, 2015, 03:30:27 PM

Previous topic - Next topic

gkaudewitz

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

Victor Kirhenshtein

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

gkaudewitz

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

tomaskir

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)

gkaudewitz

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..)

gkaudewitz

Sorry I just read that inputfields for object Tools have been implemented with 2.0-RC1....

gkaudewitz

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)


tomaskir


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;
}

gkaudewitz

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

Victor Kirhenshtein

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

gkaudewitz

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