HOW TO
Instructions provided give scripting examples that demonstrate how to use Python's subprocess module to spawn a new process while providing inputs to and retrieving outputs from the secondary script.
The subprocess module is new in version 2.4 of Python and is provided as a standard module. This module intends to replace several other, older modules and functions, such as:
*See the Python documentation for additional information about this module.
import os from subprocess import * #run secondary script 1 p = Popen([r'C:\secondaryScript1.py', "ArcView"], shell=True, stdin=PIPE, stdout=PIPE) output = p.communicate() print output[0] #run secondary script 2 p = Popen([r'C:\secondaryScript2.py', "ArcEditor"], shell=True, stdin=PIPE, stdout=PIPE) output = p.communicate() print output[0]Secondary script 1
import sys, arcgisscripting gp = arcgisscripting.create(9.3) print gp.setproduct(sys.argv[1])Secondary script 2
import sys, arcgisscripting gp = arcgisscripting.create(9.3) print gp.setproduct(sys.argv[1])
Get help from ArcGIS experts
Download the Esri Support App