File: general_command_wrapper.py

package info (click to toggle)
lyx 1.1.6fix4-2
  • links: PTS
  • area: contrib
  • in suites: woody
  • size: 26,136 kB
  • ctags: 13,679
  • sloc: cpp: 93,591; sh: 9,563; ansic: 8,253; perl: 3,489; makefile: 1,332; tcl: 163; sed: 150; python: 112; yacc: 38
file content (27 lines) | stat: -rw-r--r-- 638 bytes parent folder | download | duplicates (2)
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
26
27
#!/usr/bin/python
# This is a general wrapper script that will allow
# us to maintain security in the external material
# insets.
# Use like this:
#   general_command_wrapper.py stdin-filename stdout-filename command args
# Use "-" for stdin-filename and stdout-filename to use the normal stdio

import sys
import os
import os.path



if sys.argv[1] != "-":
	os.close(0)
	sys.stdin = open(sys.argv[1],"r")
if sys.argv[2] != "-":
	print "Redirecting" + sys.argv[2]
	os.close(1)
	os.close(2)
	sys.stdout = open(sys.argv[2],"w")
	sys.stderr = open(sys.argv[2],"w")

os.execvp(sys.argv[3], sys.argv[3:])
print "Could not run " + sys.argv[3]