usr bin python import sys import os class GetEnv def echo self string

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/python
import sys
import os
class GetEnv:
def echo(self, string):
sys.stdout.write(str(string))
def main(self):
try:
arg = sys.argv[1]
env = os.getenv(arg)
if env is not None:
self.echo(env + "\n")
except IndexError:
for envkey, envval in os.environ.iteritems():
self.echo("%s=%s\n" % (envkey, envval))
except:
self.echo("unknown error in \"%s\"\n" % __file__)
if __name__ == '__main__':
GetEnv().main()