AppleScript: Pass all command line args to two terminals
I’ve searched high and low, but can’t find something that will get me what I need. I’m looking for a way to, from Terminal, launch two different python processes with the same set of command line arguments. I'm running Yosemite (10.10.5) if that matters.
Currently, I have to open up two Terminal windows or tabs and run a command in each of them:
Terminal 1:
python app1.py -c ~/users/config -v
Terminal 2:
python app2.py -c ~/users/config -v
I’d like to get this down to one executable script. On Linux, I’ve created a script like this:
x-terminal-emulator -e bash -c "python app1.py $@"
x-terminal-emulator -e bash -c “python app2.py $@"
Of course that won’t work in OS X, but I’d love it if there was an equivalent. I could probably background one of the processes and run both in the same window, but I'd prefer to see both. It appears there is not, especially keeping the current working directory, so I looked into AppleScript.
My challenge is passing all the args (there can be more than what’s in the example above). Bash lets me use $@ to pass everything in Linux, but I can’t find an equivalent in AppleScript.
Basically, I’m looking for an AppleScript file similar to this (replacing $@ with something that actually works!):
#!/usr/bin/osascript
tell application "Terminal"
activate
my makeTab()
do script “python app1.py $@” in tab 2 of front window
my makeTab()
do script “python app2.py $@” in tab 3 of front window
end tell
on makeTab()
tell application "System Events" to keystroke "t" using {command down}
delay 0.2
end makeTab
Any help would be much appreciated! This would be my first foray into AppleScript, so forgive me if I've missed something really obvious.
MacBook Pro (Retina, 13-inch,Early 2015), OS X Yosemite (10.10.5)