?sys.argv values more literally?

Norman Shelley Norman_Shelley-RRDN60 at email.sps.mot.com
Fri Apr 28 11:43:44 EDT 2000


I need to write a frontend program that will call one of two other
programs (both of which are NOT binaries but are tcl programs therefore
they HAVE to be invoke with os.system() or "/bin/sh" has to be the first
argument to a os.execv() call).

THe frontend program must detect a "-ver someversionname" options and
remove the two words and then call the appropriate tcl program with the
EXACT arguments given on the command line (less those two words).
Problem is words in sys.argv
that were quoted on the command line look like words that were not
quoted on the command, e.g.

%frontend -ver 1.0 word1 word2 "word three" "word(three)"
argv looks like
["frontend", "-ver", "1.0", "word1", "word2",  "word three",
"word(three)"]

but this fails when os.system or os.execv is called (with frontend,
-ver, and 1.0 replaced with the tcl program full pathname (/bin/sh added
at front  for execv) as "word three" and "word(three)" are missing there
protective quotes (the /bin/sh needs to see those as one word not two
words or a word  with parens).

I need   argv to look like this:
["frontend", "-ver", "1.0", "word1", "word2",  '"word three"',
'"word(three)"']
where words that were quoted on the command line are strings with
beginning and ending quotes in the argv.

Any way to do this or get around this problem?

--
Best regards,


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20000428/f568567b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Norman_Shelley-RRDN60.vcf
Type: text/x-vcard
Size: 281 bytes
Desc: Card for Norman Shelley
URL: <http://mail.python.org/pipermail/python-list/attachments/20000428/f568567b/attachment.vcf>


More information about the Python-list mailing list