[SOLVED] Download a files from website with specified range using bash script.
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Don't post the same question multiple times; duplicate reported.
Oh please. If you cant help others, don't try messing bro. I am not that stupid to re-post same question here. This question is just a example which I currently working.
your mind is so dirty bro. keep your hands away if you can't help others.
So basically what you mean is, the person who are here in this forum for more than 10 year should be expert? I would expect some help rather than return questions what has been asked. Anyways, thanks for keeping track of my account and my knowledge.
And we would expect someone with ten years experience and at least four years asking about shell-scripts to know how to write a simple shell script; especially since you've asked about bash scripts and looping before, and even know about shellcheck. And you didn't answer the question about this being homework, because saying what it 'demands' makes it sound like a teacher is telling you what to use.
Since you know the two utility names, have you read their man pages? What have you put into your script to give you the output that you want, because there doesn't appear to be anything there. Unless you write your script to do it, it's not going to...we aren't going to write it for you. Asking over and over for someone to 'fix your code' doesn't appear as if you're putting any effort into your script, but expecting us to do it. You were given advice on debugging things, but didn't respond...you were told about brace expansion, but don't appear to have put effort into a revised script, but instead just keep asking us for it.
If you'd like help, then why don't you post the results of the hints/suggestions you've been given, and show us your updated script?
And we would expect someone with ten years experience and at least four years asking about shell-scripts to know how to write a simple shell script; especially since you've asked about bash scripts and looping before, and even know about shellcheck. And you didn't answer the question about this being homework, because saying what it 'demands' makes it sound like a teacher is telling you what to use.
Since you know the two utility names, have you read their man pages? What have you put into your script to give you the output that you want, because there doesn't appear to be anything there. Unless you write your script to do it, it's not going to...we aren't going to write it for you. Asking over and over for someone to 'fix your code' doesn't appear as if you're putting any effort into your script, but expecting us to do it. You were given advice on debugging things, but didn't respond...you were told about brace expansion, but don't appear to have put effort into a revised script, but instead just keep asking us for it.
If you'd like help, then why don't you post the results of the hints/suggestions you've been given, and show us your updated script?
So does it really bothers you?? whether I am here for 10 years or more.
I think no one is forcing you to answer. if you don't feel like answering just ignore dude. Damn! your soul is full of negativity.
So basically what you mean is, the person who are here in this forum for more than 10 year should be expert?
I would expect some help rather than return questions what has been asked.
Anyways, thanks for keeping track of my account and my knowledge.
Cheers
That is an interesting question. If you did not learn anything in ten years (about it) probably you will not learn anithing in the next 10 years (because it looks like you are not really interested).
Giving "the" complete solution means again you will not learn anything (Is this the help you are waiting for? Why?).
There were a lot of suggestion posted, so you could easily solve it - if you were interested. For example using post #6:
Code:
#!/bin/bash
echo "Enter the range of image you want to download"
read -p "Enter first range of image. log: " StartRange
read -p "Enter Last range of image. log: " EndRange
for i in $(seq $StartRange $EndRange); do
wget -q -P DownloadFolder/ http://localhost/log/log$i.log
done
if you want to use a forum like this please read the rules.
Quote:
Do not post the same discussion multiple times. Duplicate discussions can be frustrating for other members. Try and pick the most relevant forum for your post. If you are unsure put it in Linux - General.
Quote:
Do not post if you do not have anything constructive to say in the post.
Quote:
By becoming a member you agreed to adhere to these guidelines.
So does it really bothers you?? whether I am here for 10 years or more. I think no one is forcing you to answer. if you don't feel like answering just ignore dude. Damn! your soul is full of negativity. GET WELL SOON BRO!!!
This is a very typical answer and response. If it 'bothers you' that we ask you to show your OWN EFFORT in solving your own problem, that says more about you than anyone else. Not sure how it's 'full of negativity' to ask you to show your own effort to solve your own problem. And I am most certainly not your 'bro'.
AGAIN:
You know about shellcheck, and have posted about it FOUR YEARS ago. Why haven't you used it?
You have at least four years experience writing shell-scripts.
You say it 'demands' one of two tools; why?? Is this homework??
You know what those tools are; have you read the man pages?
You say what output you want; but you haven't done ANYTHING in your script to get it, so how do you expect to get that output?
You were given a suggestion on how to debug your script; did you bother to do it? Results were what???
You were told about expansion; have you addressed that??
Where is your updated script, that shows what you've done/tried based on what you've been told???
Again: have you tried echoing anything to the screen, to see what you're getting for a range???
For example; if user enters the number 4, then the script should download 4 files randomly.
Code:
for i in {1..4}; do
echo $((1 + RANDOM % 100))
sleep 1
done
for i in {1..4}; do
echo $RANDOM | cut -c $((${#RANDOM}-6))
sleep 1
done
for i in {1..4}; do
shuf -i 1-100 -n 1
sleep 1
done
for i in {1..4}; do
grep -m1 -ao '[0-9]' /dev/urandom | head -n1
sleep 1
done
for i in {1..4}; do
tr -cd 1-99 < /dev/urandom | head -c 2
sleep 1
done
Oh please. If you cant help others, don't try messing bro. I am not that stupid to re-post same question here. This question is just a example which I currently working.
..which is *NEARLY IDENTICAL* to your other thread, which (amazingly) deals with downloading files via curl/wget in a range of numbers. Again, simple loop, except instead of a range, you just have to iterate through a user-entered count....which you already know how to do. And you were given how to generate a random number in bash.
And again, I am certainly not your 'bro'.
Quote:
your mind is so dirty bro. keep your hands away if you can't help others. no one is forcing you to answer. NO ONE IS LUCKY LIKE YOU!!!!!!!!!!!!!!!!!!
Can I help you? Sure...happy to as soon as you show what effort YOU have put into your own problem. Read the LQ rules and "Question Guidelines"...this isn't the place to come to get your homework done, or have people write scripts for you.
And I am 'lucky', because I actually do my own work.
so, OP: rather than asking someone how to code something, you have to try it first. What is the point of learning coding without trying? When you try something and then get stuck, you ask for help. If you don't even try, you aren't doing your job.
Anyways I got the solution. Thanks to those who gave me straight solution rather than beating the bush around. BUT I would still say, NO ONE IS FORCING YOU TO ANSWER HERE. IT IS UPTO THE PERSON INTEREST.
Oh?? So why don't you post your solution, so others may benefit??? And asking you to show your own effort isn't 'beating the bush around', but something you should do period.
If you choose to be insulted by people asking you to do your own work, that says more about you than anyone else. Good luck...you'll need it.
Oh?? So why don't you post your solution, so others may benefit??? And asking you to show your own effort isn't 'beating the bush around', but something you should do period.
If you choose to be insulted by people asking you to do your own work, that says more about you than anyone else. Good luck...you'll need it.
so, OP: rather than asking someone how to code something, you have to try it first. What is the point of learning coding without trying? When you try something and then get stuck, you ask for help. If you don't even try, you aren't doing your job.
...but somehow it's not the same question. Only difference is instead of a user-entered range, this one wants a random number for $i. Which if a simple loop is done, you can generate the value upon entry, and just tick up a loop counter..same as ticking up a counter in the other thread.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.