]> git.lyx.org Git - lyx.git/blob - lib/scripts/general_command_wrapper.py
preliminary Thai support
[lyx.git] / lib / scripts / general_command_wrapper.py
1 #!/usr/bin/python
2 # This is a general wrapper script that will allow
3 # us to maintain security in the external material
4 # insets.
5 # Use like this:
6 #   general_command_wrapper.py stdin-filename stdout-filename command args
7 # Use "-" for stdin-filename and stdout-filename to use the normal stdio
8
9 import sys
10 import os
11 import os.path
12
13
14
15 if sys.argv[1] != "-":
16         os.close(0)
17         sys.stdin = open(sys.argv[1],"r")
18 if sys.argv[2] != "-":
19         print "Redirecting" + sys.argv[2]
20         os.close(1)
21         os.close(2)
22         sys.stdout = open(sys.argv[2],"w")
23         sys.stderr = open(sys.argv[2],"w")
24
25 os.execvp(sys.argv[3], sys.argv[3:])
26 print "Could not run " + sys.argv[3]
27