def get_var(script_path, var):
if path.isfile(script_path):<EOL><INDENT>input = '<STR_LIT>'% (script_path, var)<EOL>pipe = Popen(["<STR_LIT>"],  stdout=PIPE, stdin=PIPE, stderr=PIPE)<EOL>stdout_data, stderr_data = pipe.communicate(input=input)<EOL>if stderr_data:<EOL><INDENT>raise ShellScriptException(script_path, stderr_data)<EOL><DEDENT>else:<EOL><INDENT>return stdout_data<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise _noscripterror(script_path)<EOL><DEDENT>
Given a script, and the name of an environment variable, returns the
value of the environment variable.
:param script_path: Path the a shell script
:type script_path: str or unicode
:param var: environment variable name
:type var: str or unicode
:return: str