Yesterday’s Apple Script Execution of Start Word Suggestions for Wordle Tutorial struck a chord of interest for us. Its use of …
- macOS command line via Terminal application …
- Apple Scripting … and …
- “open” command on that command line
… opens the door to an idea we’ve wondered about before … perhaps involve multiple web browser “brands” in a single …
- web application
- command line application
- curl web application
… using … you guessed it … PHP in (what we see as) its 3 modes of use.
Here’s our first draft of apple_script_url.php we want you to download to (the Document Root of) a macOS MAMP local Apache/PHP/MySql web server environment, ideally, though you can tailor for another macOS local web server arrangement, perhaps …
<?php
// apple_script_url.php
// RJM Programming
// February 2022
$ts=date('_dmY_his', time());
if (isset($argc)) {
if (PHP_OS == "Darwin") {
if ($argc >= 2) {
if (file_exists(getenv('HOME') . '/Desktop/MyAppleScript' . $ts . '.scpt')) {
unlink(getenv('HOME') . '/Desktop/MyAppleScript' . $ts . '.scpt');
}
file_put_contents(getenv('HOME') . '/Desktop/MyAppleScript' . $ts . '.scpt', "tell application \"Terminal\"\n activate\n do script \"cd '" . getenv('HOME') . '/Desktop' . "'\" in window 1\n do script \"open '" . $argv[1] . "'\" in window 1\nend tell");
exec("cd " . getenv('HOME') . '/Desktop ; open MyAppleScript' . $ts . '.scpt');
}
}
} else if (isset($_GET['url'])) {
if (PHP_OS == "Darwin") {
if (file_exists(getenv('HOME') . '/Desktop/MyAppleScript' . $ts . '.scpt')) {
unlink(getenv('HOME') . '/Desktop/MyAppleScript' . $ts . '.scpt');
}
file_put_contents(getenv('HOME') . '/Desktop/MyAppleScript' . $ts . '.scpt', "tell application \"Terminal\"\n activate\n do script \"cd '" . getenv('HOME') . '/Desktop' . "'\" in window 1\n do script \"open '" . str_replace('+','%20',$_GET['url']) . "'\" in window 1\nend tell");
//exec('open \"' . getenv('HOME') . '/Desktop/MyAppleScript' . $ts . '.scpt\"');
passthru("cd " . getenv('HOME') . '/Desktop ; open MyAppleScript' . $ts . '.scpt');
} else if (strpos($_SERVER['SERVER_NAME'], 'localhost') === false) {
echo "<html><body onload=\" window.open('HTTP://localhost:8888/apple_script_url.php?url=" . str_replace('+','%20',$_GET['url']) . "','_self'); \"></body></html>";
}
}
?>
… and if you have downloaded, you may get some joy with it calling Google into a new web browser arrangement via the pressing of an Apple Script window Play button … or … get to the macOS Terminal prompt and type …
php /Applications/MAMP/htdocs/apple_script_url.php https://google.com
… or …
curl "HTTP://localhost:8888/apple_script_url.php?url=https://google.com"
If this was interesting you may be interested in this too.



Naming the things in a bathroom is a smarter vocabulary exercise than it first looks, because every learner already knows the room, so the words attach to objects they can see and touch instead of floating on a flashcard. Asking how many things can you name turns it into a game rather than a test, and the counting itself becomes the motivation: one more word than last time is a visible win. I like the way this kind of lesson uses a photograph as the prompt, since a picture gives every student the same starting point regardless of level, and the stronger students can move on to describing what each thing is for while beginners are still collecting nouns. The bathroom is a good choice of room too, because it is full of everyday words that textbooks often skip, the small objects people actually say out loud every morning. A daily habit of naming five new things around the house would build a working vocabulary faster than memorising lists, and this post is a good template for it.