Automator Shell arguments for a Service

Discussion in 'Mac Programming' started by yagoa, May 6, 2017.

Tags:
  1. yagoa macrumors newbie

    Joined:
    Dec 9, 2011
    #1
    What should I use instead of "echo" to pass the URL to a terminal program? Screen Shot 2017-05-06 at 21.18.45.png
     
  2. superscape, May 8, 2017
    Last edited: May 9, 2017

    superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #2
    Hi,

    I'm guessing you're wanting to pass the URLs to "youtube-dl" as a parameter, right? Also, I'm assuming that if you type:

    youtube-dl "http://some.valid.url/whatever"

    ...then it works for you.

    In which case, the passed arguments come in as the variable $@. So you need to loop through the list like this:

    Code:
    for f in "$@"
    do
      #your download code goes here
      youtube-dl "$f"
    done
    
    I wrote a short guide to doing this a little while ago here:

    https://www.ghostotter.com/making-shell-scripts-little-user-friendly/

    ...you may find it useful!

    Good luck.
     

Share This Page