urgent urgent, need help please with bash script to pass exam...
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.
you can start script with one of these (if your system has them). which one will you choose?
#!/bin/sh
or
#!/bin/bash
or
#!/bin/csh
or
#!/bin/ksh
after that you'll need to formulate some logical blocks by which you then write the code for. so maybe something like this:
[does src folder exist]
[ls of files in src dir]
[does dst folder exist]
[copy files to dst folder]
[handle exceptions accordingly]
for the other parts you'll need more logic blocks. gzip'ing should be rather easy. menu'ing should be rather easy. geez, many of those questions already say what to do.
please post when you are done, we would like to see what you came up with.
Last edited by Linux_Kidd; 11-21-2011 at 11:57 AM.
1 members found this post helpful.
Click here to see the post LQ members have rated as the most helpful post in this thread.
I checked your assignment, there's plenty of info to get started.
Quote:
Originally Posted by engrmilad
if you were lucky with however taught
Nobody taught me, there's plenty of documentation for linux to learn without a teacher. Open the terminal, type "info bash" and start reading.
Quote:
Originally Posted by engrmilad
just simply shut up and dont help..
Look, if you want "help", start asking proper question. I.e. "how I do this" or "what could I use to do that" instead of "please do my homework for me". Asking to do your homework is "no go". As I said, if you don't want to do your own homework, then head for any freelancing resource, and either pay somebody to do it for you or pay somebody to tutor you. The tutor might be a better idea, since if somebody simply does your homework instead of you, you won't avoid trouble later.
Perhaps your teacher is bad like this because during his education he also had his homework assignments made by others?
jlinkels
before you talk go check what i wrote, I bought all CBT Nuggets videos trying to get something and I will soon or later and if no one of yous believes what am saying, who cares!! I will do it for myself later .. anyways its easy guys (it's my fault) asking a help from you.. because there is no difference between yous and our teacher.. thanx genius jlinkels..
alright guys thank you indeed, my only concern was to pass my subject next week because I felt hopeless of trying and please for all those who say "show us what you tried" the problem is I have what I tried saved on a teacher's software called putty and cant have it with me so don't just come here and just find a subject to show yourselves that you are the best. I only came to this place when i felt hopeless and cant do nothing about it now coz no enough time for learning every thing now, this is my first time ever in my life asking someones help as well, anyways fuck this I dont want any help anymore.. DO NOT worry about it please...
I will watch the videos that I spent money on and learn this later in my life, and If the whole class is not getting anything right for now, then we will all pass somehow anyways..!!!
I am not really interested in reading any more ridiculous comments, because I know myself when I learn this right I bet you I will beat asses. so just simply ignore this fucking post OK??? and if there is any way to remove this post please let me know so I can remove it.....
you can start script with one of these (if your system has them). which one will you choose?
#!/bin/sh
or
#!/bin/bash
or
#!/bin/csh
or
#!/bin/ksh
after that you'll need to formulate some logical blocks by which you then write the code for. so maybe something like this:
[does src folder exist]
[ls of files in src dir]
[does dst folder exist]
[copy files to dst folder]
[handle exceptions accordingly]
for the other parts you'll need more logic blocks. gzip'ing should be rather easy. menu'ing should be rather easy. geez, many of those questions already say what to do.
please post when you are done, we would like to see what you came up with.
Brother I appreciate your help for me.. thank you very much you are the best..
before you talk go check what i wrote, I bought all CBT Nuggets videos trying to get something and I will soon or later and if no one of yous believes what am saying, who cares!! I will do it for myself later .. anyways its easy guys (it's my fault) asking a help from you.. because there is no difference between yous and our teacher.. thanx genius jlinkels..
alright guys thank you indeed, my only concern was to pass my subject next week because I felt hopeless of trying and please for all those who say "show us what you tried" the problem is I have what I tried saved on a teacher's software called putty and cant have it with me so don't just come here and just find a subject to show yourselves that you are the best. I only came to this place when i felt hopeless and cant do nothing about it now coz no enough time for learning every thing now, this is my first time ever in my life asking someones help as well, anyways fuck this I dont want any help anymore.. DO NOT worry about it please...
I will watch the videos that I spent money on and learn this later in my life, and If the whole class is not getting anything right for now, then we will all pass somehow anyways..!!!
I am not really interested in reading any more ridiculous comments, because I know myself when I learn this right I bet you I will beat asses. so just simply ignore this fucking post OK??? and if there is any way to remove this post please let me know so I can remove it.....
It's not buying videos how you learn...it's mainly reading docs, practicing, and asking politely, without calling peoples names (which you again did).
If you aren't interested in reading ridiculous comments just don't read them. Nobody is worrying about anything, but one thing I have to wonder: why post in the first place if you want the post to be removed? Doesn't make sense.
If you want to post your doubts instead of your rants about how the world won't work to your personal wish, here we are to help you.
It's not buying videos how you learn...it's mainly reading docs, practicing, and asking politely, without calling peoples names (which you again did).
If you aren't interested in reading ridiculous comments just don't read them. Nobody is worrying about anything, but one thing I have to wonder: why post in the first place if you want the post to be removed? Doesn't make sense.
If you want to post your doubts instead of your rants about how the world won't work to your personal wish, here we are to help you.
well then just dont read my posts then and fuck up
well then just dont read my posts then and fuck up
I understand your anger at what to you may seem like a less than helpful attitude displayed by most replies here*. That said however you have absolutely no reason to behave in this way.
So cut it out and start asking the right questions.
* @all: one reply of "please do not post homework questions verbatim, ask questions the right way" should suffice. Two is more than enough but three or more is pushing it. Piling in or what borders on the provocative is not what we need at LQ. So no more of that after this post, OK?
Brother I appreciate your help for me.. thank you very much you are the best..
i was just giving you some basic problem solving tips in the context of your homework. use Google to search for examples that are relevant, then modify them until your code does what the questions ask. the bottom line is, you need basic problem solving skills if you are planning on having a career that has anything to do with computers.
once you get some basic code together and you want more help, post the code along with specific relevant questions and you'll get more help from the tech savvy folks here.
i think what most of us have been telling you is, your fingers have to get more workout than ours, so start typing, etc.
Last edited by Linux_Kidd; 11-21-2011 at 07:49 PM.
i was just giving you some basic problem solving tips in the context of your homework. use Google to search for examples that are relevant, then modify them until your code does what the questions ask. the bottom line is, you need basic problem solving skills if you are planning on having a career that has anything to do with computers.
once you get some basic code together and you want more help, post the code along with specific relevant questions and you'll get more help from the tech savvy folks here.
i think what most of us have been telling you is, your fingers have to get more workout than ours, so start typing, etc.
I only read the first post and skimmed all the drama posts.
Here are some topics for you to google without the quotes. I've broken them down by problem instead of giving you a big list so you'll hopefully be a little more organized. BTW everywhere you see "man something" then you can type that in your SSH console (putty).
PART 1)
"interactive command bash"
"pipes bash"
"howto script options bash"
"man cp"
"man mv"
"man mkdir" (look at the -p switch)
"man tar"
"man gzip"
Your teacher gave you a list of files you need to back up so make a temporary directory for instance in /tmp/compfiles and then tar that directory and run it through gzip using pipes '|'. That should be more than enough information to get you started.
PART 2)
"man cut" (in particular the -f switch and -d switch.)
"man grep" (you don't have to read too much here since your teacher already gave you the command)
"redirect output bash"
"what is tilde bash"
"pipes bash"
PART 3)
"functions bash"
"interactive command bash"
"pipes bash"
The rest will basically use commands from your teacher's script. If you see a command in the script which you don't understand you can either type "man somecommand" where somecommand is the command you don't understand or you can google "man somecommand".
PART 4)
"man curl" (see also the EXIT CODES part of the man page as this will help determine the status of a run command)
"exit codes bash" (I'll give you a hint, the exit status zero '0' means that the command ran successfully)
"conditional bash" (will teach you how you can handle the exit codes)
I'll give you a big hint but you'll still have to work out the details on your own.
If you actually read most or all of the documentation I have specified so far then you shouldn't have any trouble in my above descriptions.
PART 5)
"test nic snmp"
"man snmptest"
"man snmpwalk"
I'm a little less versed in this topic though I have some experience. I'm not sure what your teach means by graph it so perhaps someone else could elaborate on that.
Be prepared.
Doing the assignments I outlined above (assuming you know nothing about Linux and Bash in general) will take you about 4-5 hours of reading and comprehension and an additional 2-3 hours of doing the assignments since you have no prior experience with the discussed utilities. I tell you how much time it takes to do it in the hopes that you won't procrastinate because this isn't something which can easily be done.
ALSO NOTE
Your teacher isn't dumb about Linux. They sound like they know what they are doing. I'm sure he had a class earlier in the term where they teach you how to use vim and the man pages (i.e. manual pages for all the commands) which you might have missed. I'm not scolding you just telling you how it is because I too was the type who always skipped my classes and decided to do the homework later.
SECOND NOTE << this one's important
The research I have presented to you (google searches included) took me about 1.5-2hrs to prepare and that includes writing up this post. As you can imagine it is quite strenuous work.
The only reason why I outlined your problems like I did was to assist your "short notice" request and to help redeem the community's fault where pointed out by unSpawn, a moderator here. I rarely do that and did this on a whim. I likely would have reacted similar to the other community members if I were in a different mood. You have to realize that we're a common community (which you are now a part of) of hobbyists and professionals who enjoys discussing Unix and Linux topics. We do not get paid and are putting in our own time and effort in good faith that you are doing an equal amount or more of work in the research process. We do assist people with homework from time to time but we never like to see someone put in minimal effort (like your first post) who expect to get something out of it. Please keep that in mind for when you post in the future and I would advise not insulting anyone. Eventually people will stop responding to your current and future posts entirely if you're rude enough. Just some friendly advice so don't take it in the wrong tone.
The only reason why I outlined your problems like I did was to assist your "short notice" request and to help redeem the community's fault where pointed out by unSpawn, a moderator here.
SAM
Brother thank you very much for your beautiful efforts and I really appreciate your respected personalty to spend time on trying to help me to get in the right direction, I really don't know what to say more than you are very generous.. Thank You and I will start search and read trying to learn something quickly in this lost time and hopefully do it ..
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.