BES Client's environment on *NIX

(imported topic written by gearoid)

It’s useful to know how the environment is set up when you’re using fixlets and tasks that execute shell scripts or shell commands.

In particular, the environment is probably not going to be the same as when you log in as a user, such as root.

The BESClient process envrionment is inherited by the process that’s running your shell command/script. This is a pretty small set of environment variables.

I use the following action script in a task to get the environment and compare it with the environment of the root. They are quite different and may explain why a script that runs perfectly when you’re logged in as root doesn’t when you run it from a task.

// get the BESClient’s env

wait bash -c “env > /tmp/besenv”

1 Like

(imported comment written by jgstew)

This is a great tip, and definitely something that is easy to get tripped up on.

So, when I create a fixlet like that and run it on RHEL 7, I get the same error as trying to run the script. Any Ideas?

Command started - wait bash -c “env > /tmp/besenv” (action:2129706)
At 10:28:06 -0400 -
Report posted successfully
At 10:28:06 -0400 - actionsite
Command succeeded (Exit Code=127) wait bash -c “env > /tmp/besenv” (action:2129706)

Is bash present on the system? It may not be the default shell or in the BESClient’s PATH.
Try using /bin/bash or /bin/sh

Those brought about the same results. What finally did work was changing for action language to sh. Thanks for the help though.