How can I make a shell script open multiple new Terminal windows that executes each their shell script? Just like asked here , but in OS X.
I've got a for-each loop which runs trough all the given arguments and should execute a script in a new Terminal window for each given argument (and pass on the argument).
This is what I've tried:
#!/bin/bash
for arg in $@ do
open -a Terminal ./somescript.sh --args $arg
done
I think you mean this:
#!/bin/bash
for arg in "$@"; do
osascript <<EOF
tell application "Terminal" to do script "echo \"$arg\""
EOF
done
Then run:
chmod +x aboveScript
./aboveScript a b "cd ef"
If you like that, change the echo
to ./somescript
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.