script-server icon indicating copy to clipboard operation
script-server copied to clipboard

expose PARAM_ variables to script value execution

Open muzzol opened this issue 4 years ago • 3 comments

Scripts configured in values for multiselect type don't get any PARAM_ variables.

I would like those variables to get exposed to listing scripts, like in this example:

    "name": "Printers Management",
    "script_path": "/opt/scripts/printers.sh",
    "description": "Add/Remove printer from machine.",
    "parameters": [
	{
	    "name": "Machine",
	    "required": false,
	    "type": "text"
	},
	{
    	    "name": "Action",
    	    "required": true,
    	    "type": "list",
	    "default": "Show",
    	    "values": [
		"Show",
		"Add",
		"Remove"
    	    ]
	},
	{
	    "name": "Printer",
	    "type": "multiselect",
	    "values": { "script": "/opt/scripts/list_printers.sh" }
	},
	{
	    "name": "Operator",
	    "required": true,
	    "default": "${auth.username}",
	    "constant": true
	}
    ]
}

Right now I can only get values passed as parameters, like: "values": { "script": "/opt/scripts/list_printers.sh ${Machine} ${Action}" }

But with complex scripts this is confusing and misleading, so I would like to get PARAM_MACHINE and PARAM_ACTION instead.

thanks for your time!

muzzol avatar Aug 31 '21 10:08 muzzol

Hi @muzzol, to be honest this would be quite complicated. At the moment, script server calls the script only if linked values are changed (i.e. Machine and Action). It has no idea, which environment parameters are used inside the script

bugy avatar Aug 31 '21 11:08 bugy

ok, thanks for your time :)

muzzol avatar Aug 31 '21 11:08 muzzol