有一个节目,我需要启动多次,并把它传递不同的参数各一次。 要做到这一点,我试着写一个简单的Python脚本如下:
import sys, os
from os.path import join
# This works, but will not launch twice
os.system('./AppName.app -AppCommandLineArg')
# This allows launching two instances but without command line arguments
os.system('open --new --background ./AppName.app')
# Attempt #1
os.system('open --new --background ./AppName.app -AppCommandLineArg')
# Attempt #2
os.system('open --new --background "./AppName.app -AppCommandLineArg"')
# Attempt #3
os.system('open --new --background "./AppName.app/Contents/MacOS/AppName -AppCommandLineArg"')
我使用的是“开放”的原因是为了能够推出应用中的多个时间。 是“开放”的正确命令使用? 任何建议如何做到这一点? 使用Linux / Mac是很新的给我。
谢谢!
编辑 - 下面是解决了这个问题,我的代码:
p0 = subprocess.Popen(['./AppName.app/Contents/MacOS/AppName', '-AppCommandLineArg'])
p1 = subprocess.Popen(['./AppName.app/Contents/MacOS/AppName', '-AppCommandLineArg'])
干杯!