Search for file and download it (curl,grep,wget?)

-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!

FCS

Posted 2016-12-04T23:28:27.110

Reputation: 1

How do you want to save every such file as whatever.jar? – gronostaj – 2016-12-05T00:02:55.990

sorry for being unclear on this, like user199239 already figured there is only one file fitting the criteria – FCS – 2016-12-05T00:14:23.123

Answers

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$')

user199239

Posted 2016-12-04T23:28:27.110

Reputation: 137

Perfect! Exactly what i was trying to accomplish – FCS – 2016-12-05T00:16:09.577

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 – 2016-12-05T04:29:52.360

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 – 2016-12-05T04:41:33.243

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$')

Empire92

Posted 2016-12-04T23:28:27.110

Reputation: 1