On Sat, Nov 11, 2017 at 12:28 AM Panupat Chongstitwattana < [email protected]> wrote:
> Hi guys. > > I'm doing some simple test here and curious if there's any difference > between these 2? > > os.environ["JOEY"] = "SOMETHING" > Popen( maya, shell=True ) > > and > > os.environ["JOEY"] = "SOMETHING" > Popen( maya, env.dict=dict(os.environ) ) > I don't understand this syntax. Is that a typo, calling a param named env.dict? Are you just asking about the difference between shell=True/False, or also with passing an env dict? Running a Popen(shell=True) will execute the command under a shell (or cmd.exe on windows). This allows the support of shell-specific constructs like pipes, variable expansion, aliases, shell startup scripts. It also has the potential for a security risk if you are accepted untrusted input for the command, since a user could tack on extra commands if you aren't careful. Running with shell=False will do a basic fork/exec of a new process, which can only be a specific command and its arguments. Passing an env dict to Popen is something you would do if you wanted to run the process in an environment that is different from the current process env. It is ideal to make a copy of the current env, modify the copy, and pass the copy to Popen, as opposed to modifying os.environ. It could also be a race condition to modify os.environ for the purpose of launching specific subprocesses. > 1 thing I notice is that, with Shell=True, maya.exe process would appear > under cmd. Does that change anything vs running under explorer.exe? > > > > > -- > You received this message because you are subscribed to the Google Groups > "Python Programming for Autodesk Maya" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/python_inside_maya/64a6fd4e-7243-437e-8e01-a386e5f7d514%40googlegroups.com > <https://groups.google.com/d/msgid/python_inside_maya/64a6fd4e-7243-437e-8e01-a386e5f7d514%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1Ly2jym8Vm%2BZ2qP0VyQ2Zb3GnrRrpyk2ewGMZ%2BnHJKvg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
