On Wed, May 19, 2010 at 7:27 PM, Carbon <nob...@nospam.tampabay.rr.com> wrote: > I am new to Python and am trying to write a GUI wrapper script in python > 2.5 to get username and passwords from Linux users to send as options to > run an app on a 2X terminal server. I came across the easygui module and > its multpasswordbox function, which made popping a dialog box and storing > the usernames very painless. > > However, subprocess.call as implemented below doesn't work. For some > reason the "-s ts.mycompany.org:80" parameter is being interpreted > differently by the application when sent from the python script than it > does when sent from the BASH script below. The :80 is the default port so > it isn't technically required, but the script doesn't work without it > either. > > Any ideas where I should look? Is subprocess.call the best way to do what > I want? Any advice would be most appreciated. > > > Here's the broken bit: > > print "Reply was:", fieldValues > print "Reply was:", fieldValues[0], fieldValues[1] > > subprocess.call(["/opt/2X/Client/bin/appserverclient", "-u fieldValues > [0]", "-p fieldValues[1]", "-s ts.mycompany.org:80", "-d corp", "-S > local", "-c 16", "-e 0xF", "-l 0x0409", "-a #1"])
RTFineM (http://docs.python.org/library/subprocess.html#subprocess.Popen ). Verbatim quote, emphasis mine: >>> command_line = raw_input() /bin/vikings -input eggs.txt -output "spam spam.txt" -cmd "echo '$MONEY'" >>> args = shlex.split(command_line) >>> print args ['/bin/vikings', '-input', 'eggs.txt', '-output', 'spam spam.txt', '-cmd', "echo '$MONEY'"] >>> p = subprocess.Popen(args) # Success! ***Note in particular that options (such as -input) and arguments (such as eggs.txt) that are separated by whitespace in the shell go in separate list elements***, while arguments that need quoting or backslash escaping when used in the shell (such as filenames containing spaces or the echo command shown above) are single list elements. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list