Tuesday, April 21, 2009

Python Study -- Get Environment


os.getenv(key, default=value)

Get the "key" environment variable, if it is not defined, use the default value as the result.

#!/usr/bin/env python
import osimport sys
VT_ROOT = os.getenv("VDE_TOOL_DIR", default = "/opt/vde/services/instances/vt2124")VT_CMD = VT_ROOT + "/bin/vde_tool"CT_CMD = VT_CMD + " ct "
print CT_CMDos.system

No comments: