On Unix, how can Iretrieve the output of a ksh function as a Python variable?
The function is called sset
and is defined in my ".kshrc".
I tried using the subparser
module according to comment recommendations. Here's what I came up with:
import shlex
import subprocess
command_line = "/bin/ksh -c \". /Home/user/.khsrc && sset \""
s = shlex.shlex(command_line)
subprocess.call(list(s))
And I get a Permission denied
error. Here's the traceback:
Traceback (most recent call last):
File "./pymss_os.py", line 9, in <module>
subprocess.call(list(s))
File "/Soft/summit/tools/Python-2.7.2/Lib/subprocess.py", line 493, in call
return Popen(*popenargs, **kwargs).wait()
File "/Soft/summit/tools/Python-2.7.2/Lib/subprocess.py", line 679, in __init__
errread, errwrite)
File "/Soft/summit/tools/Python-2.7.2/Lib/subprocess.py", line 1228, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied
Extra details:
- Python 2.7
- Ksh Version M-11/16/88i
- Solaris 10 (SunOS 5.10)