I am getting fail in the second line of concatenation. Looks, $EAMROOT is not able to pass the value. How to use environment variable inside the action script ?
UNIX one:
delete __appendfile
appendfile { concatenation “%0D%0A” of (if it starts with “PANACES_SITE_CONTROLLER_ADDRESS=” then “#” & it else if it starts with “PANACES_SITE_CONTROLLER_ADDRESS” then “#” & it else it) of lines of file "$EAMSROOT/installconfig/PanacesAgentGeneric.cfg" }
appendfile PANACES_SITE_CONTROLLER_ADDRESS={parameter “sitecontrolleraddress”}
if { not exists file “$EAMSROOT/installconfig/PanacesAgentGeneric.cfg.backup”}
copy “$EAMSROOT/installconfig/PanacesAgentGeneric.cfg” "$EAMSROOT/installconfig/PanacesAgentGeneric.cfg.backup"
endif
delete "$EAMSROOT/installconfig/PanacesAgentGeneric.cfg"
move __appendfile “$EAMSROOT/installconfig/PanacesAgentGeneric.cfg”
Windows one :
delete __appendfile
appendfile { concatenation “%0D%0A” of (if it starts with “PANACES_SITE_CONTROLLER_ADDRESS=” then “#” & it else if it starts with “PANACES_SITE_CONTROLLER_ADDRESS” then “#” & it else it) of lines of file “$EAMSROOT\installconfig\PanacesAgentGeneric.cfg” }
appendfile PANACES_SITE_CONTROLLER_ADDRESS={parameter “sitecontrolleraddress”}
if { not exists file “$EAMSROOT\installconfig\PanacesAgentGeneric.cfg.backup”}
copy “$EAMSROOT\installconfig\PanacesAgentGeneric.cfg” "$EAMSROOT\installconfig\PanacesAgentGeneric.cfg.backup"
endif
delete "$EAMSROOT\installconfig\PanacesAgentGeneric.cfg"
move __appendfile “$EAMSROOT\installconfig\PanacesAgentGeneric.cfg”
You can’t use $EAMSROOT in a path of relevance, BigFix doesn’t recognize the notation. If this is a system variable then you need to retrieve it’s value…
appendfile { concatenation “%0D%0A” of (if it starts with “PANACES_SITE_CONTROLLER_ADDRESS=” then “#” & it else if it starts with “PANACES_SITE_CONTROLLER_ADDRESS” then “#” & it else it) of lines of file ((value of variable "EAMSROOT" of environment) & “\installconfig\PanacesAgentGeneric.cfg”) }
if { not exists file ((value of variable "EAMSROOT" of environment) & “\installconfig\PanacesAgentGeneric.cfg”)}
copy "((value of variable "EAMSROOT" of environment) & “\installconfig\PanacesAgentGeneric.cfg”)" "((value of variable "EAMSROOT" of environment) & “\installconfig\PanacesAgentGeneric.cfg.backup”)"
endif
delete "((value of variable "EAMSROOT" of environment) & “\installconfig\PanacesAgentGeneric.cfg”)"
move __appendfile “((value of variable "EAMSROOT" of environment) & “\installconfig\PanacesAgentGeneric.cfg”)”
@goperiya1 It looks like you have some smart quotes in the ‘appendfile’ lines – that happens a lot with forum copying/pasting. Try changing them to plain ASCII quotes like you’re using in the ‘parameter’ lines.
Agree the “smart quotes” are definitely a problem…also consider that the environment variables of the running BESClient may differ from the environment of your QNA session, as BESClient is running without a login shell, and hasn’t executed environment entries from .login, .profile, .bashrc, etc.
You may want to create an action to just build an appendfile of the current environment variables, you may need to refactor your approach based on where these variables are defined and whether they are available to your client.
My instincts say the client’s limited execution context doesn’t include environment variables. To take advantage of them you’d have to punt into a script executing within a client-OS-native context.
As the client is not an interactive user environment, environment variables are limited. I got this just now via the Fixlet Debugger’s remote query against a CentOS system:
If you do the same thing in a root shell with the local qna, you will likely get a MUCH longer list of environment variables.
It’s likely that the variable you need is only be available in an interactive shell – e.g. something invoked via sh -i or sudo -l. (Note also that interactive shells are not the same as login shells.)
and see whether that displays the environment variable you’re trying to use. You still wouldn’t be able to pull it in Relevance (the value is different because BESClient is not running in a Login Shell), but you could reference the $variable value directly in the shell script you generate.