[Tutor] not invoking the shell from python

Shuying Wang shuying at gmail.com
Tue Jun 21 10:28:06 CEST 2005


Hi tutors,

I've got an external program that I'm calling from python with
os.popen. The problem is that I need to pass this program an arbitrary
body of text. I've tried escaping characters before passing it as
input but the shell still expands out certain characters. I noticed
with python2.4. How do I bypass the shell and hand arguments directly
to the program?

The problematic line in question looks like this:
os.popen('''rt create -t ticket set requestor='%s' owner='%s'
queue='%s' subject="%s" text="%s" status='%s' ''' %
		  (data['requestor'],data['owner'],data['queue'],
re.sub(r'\"',r'\\"',data['subject']), re.sub(r'\"',r'\\"',
data['body']), data['status'])

thanks in advance,
Shuying


More information about the Tutor mailing list