Search code examples
vxworks

Show all environment variables in Vxworks


Is there a command in the vxworks shell that lists all the environment variables and their current values? This is very much possible in unices and could be of help in some situations.


Solution

  • There is no specific command to print the global environment, however you can get there by using envShow(). envShow() shows all the environment variables for an identified task. eg:

    ->envShow tNet0
    (global environment)
    value = 21 = 0x15 = __local_cie + 0x1
    

    This example prints the environment for tNet0, which is using the global environment. There are no environment variables displayed, as I don't have any set.

    You can show the environment of the calling task as well:

    ->envShow 0
    (private environment)
    value = 22 = 0x16 = __local_cie + 0x2
    

    This shows that the calling task - in this case tShell - uses a private environment. Again, there are no variables set, otherwise they would be displayed.

    And lets set an environment variable just to prove it works:

    ->putenv("bar=foo")
    value = 0 = 0x0
    ->envShow 0
    (private environment)
    0: bar=foo
    

    If you are willing to do a source build, you could modify envLib.c to add a command to directly dump the global environment, which would be fairly trivial. Alternatively, just use envShow as described. You may need a little trial and error to find a task using the global environment.