In a vxWorks Real-Time process, you can pass environment variables as one of the parameter of the main routine.
How do you use the environment variables in the kernel context?
Vxworks environment variable support is provided by the envLib.
use putenv("VAR=value") to set the value of the environment variable.
use char* var = getenv("VAR") to retrieve the value.
Call this directly from the VxWorks shell:
putenv "<VARIABLE NAME>=<VALUE>"
replace with your environment variable name and with the value you want to set it to.
Related
When using CMakePresets.json the documentation states that I can use either $env{<variable-name>} or $penv{<variable-name>} to query environment variables.
Is it possible to specify a default value in case the environment variable is not set?
Note:
Since the variable that I am trying to set is also inside the presets, I can't handle the issue inside a CMake script.
If default values are not supported is there any workaround with which I could achieve the same inside the presets file?
I have environmental variable called ENV, which holds the DEV,QA OR PROD region as value. When the server.xml loaded it includes the corresponding db configuration using this variable. For ex: db-config-${env.GAH_ENV}.xml
I would like to pass the same value to the batch job xml as a job parameter or properties to any of the class. How Can I do that.
below code snippet not working
<property name="environment" value="${env.GAH_ENV}"/>
The short answer is that using a batch property may not be a good solution and you might consider something else like MicroProfile's #ConfigProperty.
The reason is there's not a built-in way to access environmental variables through JSL substitution. There is also not a convenient way for one artifact to set a property value to be used by a second artifact running later within the job execution.
In the special case that you are starting the job from within the same JVM it will execute, of course, you could pass the env var value as a job parameter.
But in the general case, if you can change the Java code and you don't really need a batch property I would use a MicroProfile Config property instead, injected via #Inject #ConfigProperty.
By doing so you lose the batch-specific substitution precedence, including the override available via job parameters passed with the submit/start. You also give up the ability to use this property in other JSL substitutions (to "compose" its value into other batch properties via other substitutions).
But you at least get a property with its own various levels of precedence/override (e.g. server config, env var, microprofile-config.properties), which is more flexible than just always reading the env var via System.getenv( ).
This is certainly an area to consider for the next version of the (now-Jakarta) Batch spec.
How is it possible to reference a variable within a variable in the new scripting system of VSTS?
e.g:
RemoteMachineFqdn: somemachinename.somedomain
RemoteMachineUncPath: \\$(RemoteMachineFqdn)\c$\
In the aforementioned example, assume there are tasks that both use CMD and Powershell scripts with the given variables. I tried using the the variables by referencing their values from the environment but it does not work for both scenarios since %variable% works only in CMD and $env:variable - only in Powershell.
What is the standard way to do it?
What you are looking for is Logging Commands. To invoke a logging command, simply emit the command via standard output. For example, from a PowerShell task:
##vso[task.setvariable variable=testvar;]testvalue
This example sets a variable in the variable service of taskcontext. The first task can set a variable, and following tasks are able to use the variable. The variable is exposed to the following tasks as an environment variable.
We have a VNext build definition, on the Variables tab we have added a few custom variables. In one of the variable values we refer to another variable, i.e.
FileDescription = $(Build.DefinitionName)
However it appears that when we reference it in a PowerShell script the FILEDESCRIPTION environment variable exists but the value is not expanded(it contains "$(Build.DefinitionName)" ) and is treated as a string literal.
The documentation appears to suggest that we should be able to refer to it and it will be subsituted at run-time -
https://msdn.microsoft.com/en-us/library/vs/alm/build/scripts/variables
Is there a way to get TFS to automatically expand the variable at runtime?
In vNext build, it seems not expanded the variable everywhere.
For example, in MSBuild-Arguments, /p:OUTPUT="$(FileDescription)" is expanded to /p:OUTPUT="(the name of build definition)" , but in powershell it will only prints "$(Build.DefinitionName)" directly.
Try to use below Workaround: Try to use the corresponding generated environment variables (for example $env:Build.DefinitionName).
$FileDescription = $env:Build.DefinitionName
Note: If you need to change the path, you have to change the PS script instead of a build variable.
VxWorks how to get address of local variable to see the memory contents.
It depends on the context.
In the code, like mouviciel mentioned, simply use the address of operator (&):
printf("var addr = %x", &var);
If you are in a vxworks host or target shell:
you can see global variables and static variables by simply entering the variable name.
-> var
var = 0x103b4188: value = 10 = 0xa
->
This gives you the address of the variable and the content.
However, this would not work with a local (automatic) variable, as it is on the stack.
The shell doesn't have a neat way of saying "show me the stack variable for Task X".
This is like any other C environment: address of (local or global) var is &var.