Using the Operating System Environment Variables
It can be usefull to retrieve the Operating System environment variables. The following examples show how to retrieve this list:import os
ftrg = open('c:/temp/listenv.txt', 'w')
try:
envDict = os.environ
osCurrentDirectory = os.getcwd()
print >> ftrg, 'Current Directory: %s' % osCurrentDirectory
print >> ftrg, '=============================='
print >> ftrg, 'List of environment variables:'
print >> ftrg, '=============================='
for aKey inenvDict.keys():
print >> ftrg, '%s\t= %s' % (aKey, envDict[aKey])
print >> ftrg, '=============================='
print >> ftrg, 'Oracle Data Integrator specific environment variables:'
print >> ftrg, '=============================='
for aKey inenvDict.keys():
ifaKey.startswith('SNP_'):
print >> ftrg, '%s\t= %s' % (aKey, envDict[aKey])
finally:
ftrg.close()
To retrieve the value of the USERNAME environment variable, just write:
import os
currentUser = os.environ['USERNAME']
Thank you for your post. This is excellent information. It is amazing and wonderful to visit your site
ReplyDeleteOracle Data Integration Training in Bangalore