Python subprocess


#1

How to use python subprocess module to open maya software & run command or script at startup?? like we do in windows command prompt
[color=white]
[b]Microsoft Windows [Version 6.2.9200]
© 2012 Microsoft Corporation. All rights reserved.

C:\Users\Rambo>“C:\Program Files\Autodesk\Maya2013\bin\maya” -command “polySph
ere”
[/b]
[/color]


#2

Found the solution
subprocess.Popen([r"C:/Program Files/Autodesk/Maya2013/bin/maya.exe", ‘-command’, ‘polySphere’])


#3

Hi is there any alternative way to do same thing ??


#4

I might not have this 100% right, since I’m not at maya right now, so straight of the top of my head…
I often use QProcess (PyQt4 or PySide)
Heres a PyQt4 example…

from PyQt4.QtCore import QProcess
cmd = 'C:/Program Files/Autodesk/Maya2013/bin/maya.exe -command polySphere'
pro = QProcess()
pro.startDetached(cmd)

David