How to download file with bash
Improve this question. Chris Snow. Chris Snow Chris Snow 3, 4 4 gold badges 21 21 silver badges 30 30 bronze badges. I can't remember now if gawk was available, though I'd love to see a gawk based solution if you have one : — Chris Snow. Add a comment. Active Oldest Votes. Update: as mentioned in the comment, the approach outlined above is simplistic: the read will trashes backslashes and leading whitespace.
Bash can't deal with NUL bytes very nicely so binary files are out. Improve this answer. So you answered your own question at the same time as you asked it. That's an interesting time machine you have ; — Meer Borg. MeerBorg - when you ask a question, look for the tick box 'answer your own question' - blog. Can I explain the code? Not yet! But it does work on cygwin. Just a note: This won't work with some configurations of Bash. I believe Debian configures this feature out of their distribution of Bash.
Urgh, while this is a nice trick, it can too easily cause corrupt downloads. None of this I see mentioned in the answer. Show 4 more comments. Use lynx. Note lynx -source is closer to wget — Steven Penny. Hey, so this is a really late comment but how do you save the output of the telnet command to a file?
Connected to www. I'm in a situation where I can only use telnet, I'm trying to make a chroot jail with the least frameworks possible. This won't handle binary transfer files—it will fail on null bytes. Wildcard, i do not understand , i've edited with a binary file transfer example containing null bytes , can you point me what i'm missing? Wildcard, heheh, yeah that looks like it should work, since it reads the actual file data with cat. I'm not sure if that's cheating since it's not purely the shell , or a nice solution since cat is a standard tool, after all.
But , you might want to add a note about why it works better than the other solutions here. Wildcard, I added the pure bash solution too as an answer below. And yes, cheating or not, this is a valid solution and worth an upvote : — ilkkachu. Taking the " just Bash and nothing else " strictly, here's one adaptation of earlier answers Chris's , 's that does not call any external utilities not even standard ones but also works with binary files:!
Isn't echo a standalone -non shell- binary? Bash has echo and printf as builtins it needs a builtin printf to implement printf -v — ilkkachu. Considering that other answers don't respect the question requirement bash only , I think this is actually better than the lynx solution, as Perl is surely more likely to be preinstalled that Lynx.
Based on Chris Snow recipe. Yecheng Fu Yecheng Fu 51 1 1 silver badge 3 3 bronze badges. It worked, But I found a concern, when I use this scripts, It keep wait several seconds when all data is read finished, this case not happen in Chris Snow answer, anyone could explain this? I edit this answer with tag variable is correct set, it work well now.
Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast what if you could invest in your favorite developer? Who owns this outage? Building intelligent escalation chains for modern SRE. Featured on Meta.
Now live: A fully responsive profile. Reducing the weight of our footer. Add a comment. Active Oldest Votes. Ottavio Campana 3, 5 5 gold badges 29 29 silver badges 56 56 bronze badges.
Since the question is locked and I cannot post as an answer, I will write it as a comment. Of course you can change the URL to your needs. More can be found here — Murat Aykanat. Jens Schauder Jens Schauder I have also needed to do this Linux noob. What I have done is to use Firefox on my Win desktop to accept the license then start download. As soon as the download starts, open the download dialog and cancel the download. Then rightclick on the cancelled item and choose "copy download link".
You can now use this link in the wget command paste it in the terminal window. The Overflow Blog. Podcast what if you could invest in your favorite developer? Who owns this outage? Building intelligent escalation chains for modern SRE. Featured on Meta. Now live: A fully responsive profile. Reducing the weight of our footer. Visit chat. Related Hot Network Questions.
0コメント