Invoking a terminal command in Terminal.app from a Worksheet

33 views
Skip to first unread message

Greg Raven

unread,
Jun 20, 2020, 11:52:30 AM6/20/20
to BBEdit Talk
This is probably very simple, but each of my attempts has failed.

I have a worksheet that opens  CodeKit and GitHub Desktop, but I'd also like it to open Terminal and create a PHP server, too.

I can create the server from a worksheet command, but I would prefer that it be do in the Terminal.

I created a separate .sh file with the appropriate PHP command for creating the server, but I can't figure out how to call it.

Any thoughts?

Fletcher Sandbeck

unread,
Jun 20, 2020, 12:14:20 PM6/20/20
to bbe...@googlegroups.com
You can execute a command in the terminal with Applescript like this:

tell application "Terminal"
do script "echo foo"
end tell

You can execute an AppleScript in the terminal with osascript. You include each line of the script as a separate -e parameter. Putting those together this runs a one line echo in the Terminal.

osascript -e "tell application \"Terminal\"" -e "do script \"echo foo\"" -e "end tell"

Hope this helps,

[fletcher]


--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/77e63b77-3070-4507-9bb9-19a24f0788c2o%40googlegroups.com.

Greg Raven

unread,
Jun 20, 2020, 1:35:26 PM6/20/20
to BBEdit Talk
Excellent. Thanks.


On Saturday, June 20, 2020 at 9:14:20 AM UTC-7, flet...@cumuli.com wrote:
You can execute a command in the terminal with Applescript like this:

tell application "Terminal"
do script "echo foo"
end tell

You can execute an AppleScript in the terminal with osascript. You include each line of the script as a separate -e parameter. Putting those together this runs a one line echo in the Terminal.

osascript -e "tell application \"Terminal\"" -e "do script \"echo foo\"" -e "end tell"

Hope this helps,

[fletcher]

On Jun 20, 2020, at 8:52 AM, Greg Raven <greg...@gmail.com> wrote:

This is probably very simple, but each of my attempts has failed.

I have a worksheet that opens  CodeKit and GitHub Desktop, but I'd also like it to open Terminal and create a PHP server, too.

I can create the server from a worksheet command, but I would prefer that it be do in the Terminal.

I created a separate .sh file with the appropriate PHP command for creating the server, but I can't figure out how to call it.

Any thoughts?

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages