Sounds like a good usage case for Perl rather than bash. The former has good Unicode support and you can use the standard lib + Mojolicious to fetch data from the web and serve other data to Safari. No need for bash + command line tools + PHP + web server.
Re:Scripting the Haiku GUI with hey
by peterburkimsher on Wednesday November 15, 2017 @01:17AM
(#15701799)
I'm not trying to serve data to Safari (usually), I'm trying to read data from Safari. I often need to get the source of a webpage that's already loaded after a login screen, or with some user interaction.
For example, scrolling down to load all my Facebook messages into the left-hand bar. Or segmenting text into 5000-character blocks, copy-pasting into Google Translate, and getting the output.
With any command-line tools, it would be a hassle, if it's possible at all. With AppleScript, it's easy.
Re:Scripting the Haiku GUI with hey
by waddlesplash on Sunday November 19, 2017 @12:34PM
(#15734844)
You realize that "hey" is just the command-line interface to Haiku's view scripting system, right? We don't have a JS/Python interface (yet), but the C++ interface is well documented (see this: https://www.haiku-os.org/legacy-docs/bebook/TheApplicationKi... for an introduction, and also hey's source code: https://github.com/haiku/haiku/blob/master/src/bin/hey.cpp).
Re:Scripting the Haiku GUI with hey
by jcelerier on Wednesday November 15, 2017 @04:24AM
(#15702536)
> For example, scrolling down to load all my Facebook messages into the left-hand bar.
sounds like an X-Y problem. Why wouldn't you just use the facebook API ?
Re:Scripting the Haiku GUI with hey
by peterburkimsher on Wednesday November 15, 2017 @04:45AM
(#15702637)
I don't think there's an API to export all my messages.
File reading and writing are easy. Getting and setting track data in iTunes is easy. Finding selected items in the Finder is easy. I've been using more "do shell script" recently as my knowledge of command-line tools increases.
It's slower to run than other languages, but when I just want a quick one-off script to generate some data, it's faster for me to code it in AppleScript instead of spending hours debugging it in another language.
All my processing for PlinyPedia ( http://peterburk.github.com/pliny ) was in AppleScript - splitting the XML into separate files grouped into folders, naming those folders, moving the footnotes to the bottom and adding links to quickly move up and down, and finally generating a basic iUI interface.
I also wrote scripts to transpose chord progressions to Roman Numerals by looking up the values in a table, select cells diagonally in Excel, and turn my Facebook friends list into an iTunes database. (The iTunes database is URL tracks that trigger a PHP script running locally that opens Safari with the URL - it's basically a bookmarks manager with Smart Playlists. If you can recommend a better database, please do.)