import sys from PySide import QtCore # create QProcess object process = QtCore.QProcess() # set command to run external script process.start('python', ['/path/to/script.py']) # get output from external process process.waitForFinished() output = process.readAllStandardOutput() sys.stdout.write(str(output))
from PySide import QtCore # create QProcess object process = QtCore.QProcess() # set command to start shell process process.start('bash') # write commands to stdin of shell process process.write('echo "Hello World!"\n') process.write('exit\n') # wait for shell process to finish process.waitForFinished()This example shows how to use QProcess to start a shell process and execute commands in it. The process.write() method is used to write commands to the stdin of the shell process, and the process.waitForFinished() method is used to wait for the shell process to complete. Package library: PySide