6 ms·
Wcurl: a curl wrapper to download files
- efitz 2y agoI appreciate it, but why not just: alias wcurl="curl -# -O $1" (I just tested this on MacOS).
- nicce 2y agoCurl does not handle reconnections or use caching like wget, for example, by default. And many other things which includes actually quite many arguments. You can see the list from this project.
- wakawaka28 2y agoWhy not just use wget if you need all that? Wget does yet more useful things.
- nicce 2y agoThen you would need two tools instead of one
- wakawaka28 2y agoSo? The tools are miniscule. Use the right tool for the right job. Shoehorning curl into the role of wget is silly.
- bigiain 2y agoBUT BUT BUT - neither wget nor curl let me read my email! BRB, forking curl to add email client support. https://programmingphilosophy.org/posts/zawinskis-law/ https://programmingphilosophy.org/posts/zawinskis-law/
- gertop 2y agoGood news then, because curl supports IMAP!
- nicce 2y ago> Shoehorning curl into the role of wget is silly. How is it silly if the identical functionality is there, but you just need to use more command-line arguments?
- wakawaka28 2y agoThe functionality is not identical. Wget is much more high level. You should not need to be an HTTP and curl expert to download a file lol.
- ocodo 2y agoI've been trying to tell people my hammer is perfect for cutting their hair, they won't listen. Until... I show them. They become unresponsive, but their hair is removed. Job done.
- dudus 2y agoMacOS comes with curl but no wget by default. Sure you can easily install it with homebrew. But it would be nice to have wget functionality by default.
- anotherhue 2y agoI felt the same but upon checking they do more than I expected. I like it.
- guilherme-puida 2y agowcurl does a lot more than that, though: parallel downloads, retries, following redirects (and other things, that are all written in the blog post). There's also some value in providing a ready-to-use wrapper for users that install the curl package. Maybe wcurl will also show up in other distributions after a while, especially since Daniel also likes the idea.
- est 2y ago> parallel downloads, retries, following redirects There's aria2
- deleted 2y ago[deleted]
- emmelaich 2y agoYou often want redirection too, so -L for --location.
- hackernudes 2y agoTotally agree! That one has burned me a lot. I generally use 'curl -LO' now instead of wget.
- CJefferson 2y agoThe alias is closer to: alias wcurl = curl -# -O $1 --location --remote-name --remote-time --retry 10 --retry-max-time 10 --continue-at -" the main reason I use wget is because it automatically retries downloads, which is vital for my not-so-great internet, and an option I wish was on in curl by default, as half the world uses curl, and then keep trying to automatically download 400MB files, which I have trouble finishing. Then, if you look at the script, it's basically that, with some minor cleaning up and nicer error handling.
- jmprspret 2y agoFWIW, I think you can add some of those options to .curlrc if you wanted them to be added every time you invoke curl.
- out-of-ideas 2y agocorrect; .curlrc for the win! and you can use `-q` to have it exclude the curlrc and use only args you pass to it. curl has such an amazing amount of power, but also means it has a lot of options to utilize a lot of things folks take for granted (exactly like retries, ect)
- lloeki 2y agoMakes me think that probably a lot of unattended shell scripts out there should use -q in case someone has a .curlrc altering the behaviour of curl, and thus breaking the expectations of the script. Maybe even should be a shellcheck rule.
- out-of-ideas 2y agosame can be said for wget with --no-config (and really any app that runs on any system) - if you're in the business of automating it, those config-features need to not be ignored (or down right overwritten to your scripts desire) in docker-containers though, its more safe to assume no pre-loaded rc files are embedded (but 100% want to check your source-container for things like that) - but for running in some users workspace, the need to be careful is real. most of the time though, those options should be safe; only really need to not have auto-retries are when trying to get super accurate date (like observing odd behavior, you dont want thing to simply "auto-work" when finetuning something, or triaging an upstream-server or dns issue) i often write my scripts execing calls like `\curl -q ...` such that i get no user's alias of curl and ensures a consistant no-config amongst my system and others (although gnu curl vs mac curl (and other binaries of gnu vs mac vs busybox) are always the real fun part). (if the user has their own bash-function of curl then its on them for knowing their system will be special compared to others and results maybe inconsistent)
- vietvu 2y agoI felt weird reading the titles too, because maybe 2-3 years ago I have downloaded with `curl`, so why this? And also, I am pretty sure `wget` can do it and better too.
- samueloph 2y agoAs others pointed out, you can do that, you can also set them in .curlrc, or you can write a script if you want to allow for multiple URLs to be downloaded in parallel (not possible with an alias), or now you can just use wcurl :) Note: wcurl sets a bit more flags than that, it also encodes the whitespaces in the URL and does parallel downloading of multiple URLs.
- deleted 2y ago[deleted]
- tssva 2y ago“or now you can just use wcurl :)” Sadly I can’t since it is dependent upon the util-linux version of getopt which means it fails on bsd and macOS systems. Understandable since it is always available on the specific target the script was written for and it does make life easier.
- samueloph 2y agoargh, we are looking into fixing that now. I knew getopt was linux-specific but I thoughts the only impact was that the long form argument (--opt) would not work. I turns out it doesn't run at all instead. We should be able to fix this within the next few days, thank you!
- samueloph 2y ago> We should be able to fix this within the next few days, thank you! It's fixed now, should work in non-linux environments.
- throwaway984393 2y agoThis happens so often. A developer could just read a man page or learn something deeply by example, but they don't. Instead they struggle for the rest of their lives in ignorance, even going so far as to adopt a hack to avoid having to learn a new thing. They will go far out their way to not learn a new thing, and over time, cause themselves untold misery.
- saghm 2y agoI think there's a bit more nuance than just ignorance. In some ways, I think reinventing the wheel is almost inevitable when we require backwards compatibility but prefer sane defaults. The expectations around what exactly should happen when making an HTTP request have evolved over time, but we can't change the way that `curl` behaves by default with potentially breaking stuff all over the place. In the same way that I don't judge people who use MacOS because it "just works" instead of using Linux like me, I don't think it's fair to treat people who don't want to spend a lot of time learning how to ask a tool to do what another tool will do without needing to spend any extra effort as if they're somehow failing as competent developers.
- notcrazy69 2y agoExcept there are about a million ways to do this that don't involve releasing another tool. Everyone I know (including myself) would make an alias, that's entirely what they're for. If you want to get really fancy, you could make it a function in your shell's rc file. Or if you're REALLY zesty, you could even write an entire shell script for it. To a senior, tools like this make no sense, because they're unnecessary, and contribute to bloat and waste, both for systems, and for the time spent.
- deleted 2y ago[deleted]
- cobalt 2y agoman pages vary in complexity/readability, and for occasional use, is probably way more painful
- 2y ago
- ehPReth 2y agois there a way to make curl do wget style progress output? i like curl but would love that kind of meter
- dryark 2y agoIt isn't exactly what you are asking for but could be adapted to do that: https://github.com/dryark/curl_progress https://github.com/dryark/curl_progress
- samueloph 2y ago"curl --progress-bar" does that "wcurl --opts="--progress-bar" URL" I was wondering if that should be the default for wcurl, but the bar only works for downloading single files, I was afraid of users thinking there's a bug whenever they downloaded more than one file if the bar wasn't there anymore.
- elygre 2y agoIt does sound like a request for “curl —-wget”, which I wholeheartedly support.
- samueloph 2y agoThat might be a nice improvement, but I believe people want a single command without any arguments for this use case.
- dudus 2y agoI can't speak for other people. But for myself I'd rather have it as a --option than another command. I dislike tools that install a lot of different commands, it just gets harder to remember them all.
- rf15 2y agoThat argument doesn't make sense at first glance: how is lots of differen't commands harder to remember than lots of different --options?
- lazyasciiart 2y agoone command can list all it's options with tool -h?
- drchaos 2y agoalias wget='curl --wget', then?
- lofaszvanitt 2y agoIt's not a nice move to hijack someone else's program+popularity and include it as an option in yours...
- kasabali 2y agoI use `curl -JLOC-` It's easy to remember, JLO is jlo, C is continue, - for symmetry.
- moontear 2y agoStealing this, but had to lookup the parameters. It does work, but it should be `-C -` with a space. Also I like progress bars so my alias for now is: curl -#JLOC - * -# Progress bar instead of the standard meter * -J Use the server-specified Content-Disposition filename instead of extracting a filename from the URL * -L Follow redirects * -O Write output to a local file (download) * -C - Resume transfers Maybe a good mnemonic would be something along the lines of jlo liking hashtags?
- cholantesh 2y ago>* -J Use the server-specified Content-Disposition filename instead of extracting a filename from the URL Can't wrap my head around how -J maps to remote header name...still, this was super useful, thanks!
- kasabali 2y ago> but it should be `-C -` with a space Works just fine without it
- moontear 2y agoNot in my Debian distro and also documented differently in the man pages. If it works for you: nice
- wodenokoto 2y ago“jlo” as in Jennifer Lopez or how does that mnemonic work?
- kasabali 2y agoExactly.
- INTPenis 2y agoI just don't get this, you can't remember two arguments so you invent a whole program. Personally I never had any problems using curl to download files, nor remembering tar arguments.
- TheAlfGalf 2y agoI think that’s pretty ungenerous a take. Wrappers have a proven history of being really valuable contributions to tools (look at GCC and clang), I think making tools easier to use in a great goal.
- taskforcegemini 2y agobut you will reach a point where remembering all tiny "tools" like this becomes more work than learning parameters of the actual tool
- dim13 2y agoA simplest alias `dl='curl -O'` just does the same for me.
- omerhac 2y agoyep, thought exactly the same thing
- chewz 2y agoalias wget='echo "using httpie as wget";http -d'
- deleted 2y ago[deleted]