cannot unset env variables from script

Posted by w00t on Server Fault See other posts from Server Fault or by w00t
Published on 2010-12-29T14:19:52Z Indexed on 2010/12/29 14:55 UTC
Read the original article Hit count: 237

Hi,

I am trying to unset all environment variables from within a script. The script runs fine but if I run env it still shows all the variables set.
If I run the command from CLI, it works and the variables are unset.

unset `env | awk -F= '/^\w/ {print $1}' | xargs`

Have any idea how to run this from a script?
Also, have any idea how to source /etc/profile from a script? This doesn't work either.

I need to set variables with same names but different paths, depending on the instances my users need.

© Server Fault or respective owner

Related posts about bash

Related posts about script