-1

i am trying to setup a command with curl and grep that lets me search for a specific pattern on a website and downloads the target link.

i have tried countless ways with curl wget and whatnot but couldnt find a solution. my researches werent particulary helpful aswell.

so what i am trying to do is:

search a website (http://ci.athion.net/job/FastAsyncWorldEdit/lastStableBuild/) for every file starting with "FastAsyncWorldEdit-bukkit-" and ending with ".jar" and then save it as whatever.jar

The tutorials i found seem to not work on jenkins

thank you for any help!

2
  • How do you want to save every such file as whatever.jar?
    – gronostaj
    Dec 5, 2016 at 0:02
  • sorry for being unclear on this, like user199239 already figured there is only one file fitting the criteria
    – FCS
    Dec 5, 2016 at 0:14

2 Answers 2

0

As far as I see correctly, on the page is just one jar file fitting your criteria.
Here is a nasty one liner, that does the job.

wget -c $(curl -s http://ci.athion.net/job/FastAsyncWorldEdit/lastStableBuild/ | tr '=' '\n' | grep FastAsyncWorldEdit-bukkit- | awk -F '"' '{ printf "http://ci.athion.net/job/FastAsyncWorldEdit/lastStableBuild/" $2"\n"}' | grep 'jar$')
3
  • Perfect! Exactly what i was trying to accomplish
    – FCS
    Dec 5, 2016 at 0:16
  • O well, any chance you can explain to me whats going on here? because im kinda confused now why this works but this: wget $(curl http://builds.enginehub.org/job/worldedit/last-successful?branch=master | tr '=' '\n' | grep worldedit-bukkit | awk -F '"' '{ printf "http://builds.enginehub.org/job/worldedit/last-successful?branch=master" $2"\n"}' | grep 'jar$') wont?
    – FCS
    Dec 5, 2016 at 4:29
  • i have this doing the job for me now but jesus christ i cant get any of that :/ curl -L --compressed (curl --compressed "http://builds.enginehub.org/job/worldedit/last-successful?branch=master" 2> /dev/null | grep -o '<a .*href=.*>' | sed -e 's/<a /\n<a /g' | grep worldedit-bukkit | sed -e 's/<a .*href=['"'"'"]//' -e 's/["'"'"'].*$//' -e '/^$/ d') > worldedit.jar 2>/dev/null ...i didnt put it in code because i didnt know how to escape the "`" already in there...
    – FCS
    Dec 5, 2016 at 4:41
0

There are permalinks on the release page, which might be simpler: https://github.com/boy0001/FastAsyncWorldedit/releases/

Also, the awk concatenates the url with the found link, but the second page uses absolute paths, so you don't want to join them:

wget -c $(curl -s http://builds.enginehub.org/job/worldedit/last-successful?br‌​anch=master/ | tr '=' '\n' | grep worldedit-bukkit- | awk -F '"' '{ printf $2"\n"}' | grep 'jar$')

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .