Hi there,
This problem seems to have different solutions depending on how the command is launched.
Is there a reliable way to do this?
This will work in cmd.exe but not with subprocess.Popen(command, shell=True):
maya.exe -hideConsole -command python(\"print('TEST')\")
RESULT using cmd.exe:
python("print('TEST')")
RESULT using subprocess:
python(print('TEST'))
This work subprocess but not in cmd.exe:
maya.exe -hideConsole -command python(\\\"print('TEST')\\\")
RESULT using cmd.exe:
python(\"print('TEST')\")
RESULT using subprocess:
python("print('TEST')")
This doesnt seem to work in any case:
maya.exe -hideConsole -command python(""print('TEST')"")
RESULT:
python(print('TEST'))
Error: line 1: invalid syntax #
I tried @Theodox answer with base64 and his launch_maya() function, but I can’t seem to make it work, here’s the result once maya has started:
python("import base64; exec (base64.urlsafe_b64decode(aW1wb3J0IHN5czsgcHJpbnQoImhlbGxvIHdvcmxkICIgKiBpbnQoc3lzLmFyZ3ZbLTFdKSk=))");
Error: line 1: invalid syntax #
Is there a reliable way to do this using subprocess.Popen and cmd.exe without modifying the command?
Another problem:
This work:
maya.exe -hideConsole -command python(\\\"print('TEST')\\\")
RESULT
TEST
This does not:
maya.exe -hideConsole -command python(\\\"from maya import cmds\\\")
// Error: python("from; //
// Error: Line 1.14: Unterminated string. //
I don’t understand the difference between the two lines. Why would the second command not work when the first one does?