Creating a service - feeding to another program

I would like to create a service, but something that is a little more complex than i can figure out how to do with automator. Something like:

  • Get URLs from selected text (i can find that)
  • Send those links to the PinBoard API for processing (adding to my pinboard list)

I can use ruby or python or whatever to send the links to the API, but I am not sure how to go about sending the links to the script I would write .

Anyone have any ideas?


Maybe just write them to file, one per line and then trigger the script to process (and then delete) the file.

ah! the trigger the script is the part that i am not sure how to do… use something like hazel?

Automator Service might be a good entry point.

The ubiquitous Keyboard Maestro is always a choice too.

yeah… i got that far… i am just trying to figure out how to say… “send this input to this script”… unless we can’t do that, and can only send to AppleScript?

In item 4 on the Envato Tuts link, you’ll see you can add both AppleScript and Shell Script. Use the AppleScript in that example to get the selected text. Use additional lines of AppleScript to save it to a file. Then run your shell script to read the content of the file and process it. Bundle it all up in a service, Keyboard Maestro, purely an AppleScript script (it could execute a shell script),…

AH! i just saw this… i don’t know why i didn’t see it before… setting up my service now…

thanks so much!

1 Like

Okay, for completion’s sake, I’ll post the results of my experiment.

I figured I would just write the script in ruby, since there are libraries to do everything, and the end product would be only a few lines or so. It turns out that this is a bit more hellish than I anticipated.

It turns out that this, while a giant pain, is quite doable, but unfortunately, not really shareable.

  • The automator gives you the choice to run using system ruby, or via a few different shells.
  • My day job is as a ruby developer, so my ruby environment is super customized. I had to do serious brain surgery to get the automator to run the script.
  • There were too many extra things that I would not want to ask a user to do to get my solution to work.

So, while everything mostly works, it’s still not something I would feel comfortable having someone add to their machine.

I am thinking of rewriting it in either swift or c++, so that I can provide a command line application that doesn’t have all the requirements that ruby has.