Reputation: 1708
I want to open new terminal and pass some values on OSX. I tried this code:
open_new_terminals_automatically()
{
osascript -e 'tell application "Terminal" to do script "cd $1; $2"'
}
# call the function and pass arguments
open_new_terminals_automatically "/root/var/fome_path" "some_commnds -argument"
This is very simple example to explain what I want to do. How I can implement it to run as bash script on OS X.
Upvotes: 2
Views: 1166
Reputation: 1537
What you have almost works, except you need double quotes instead of single quotes for the variable expansion to work properly.
Just create a script run.sh
with contents
osascript -e "tell application \"Terminal\" to do script \"cd $1; $2\""
Then you can call it with sh run.sh "/root/var/fome_path" "some_commnds -argument"
.
If you want this all done in one script, then just do
open_new_terminals_automatically()
{
osascript -e "tell application \"Terminal\" to do script \"cd $1; $2\""
}
# call the function and pass arguments
open_new_terminals_automatically "/root/var/fome_path" "some_commnds -argument"
Upvotes: 2