LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Closed Thread
  Search this Thread
Old 11-11-2013, 12:54 AM   #1
HeLpInLiNuX
LQ Newbie
 
Registered: Nov 2013
Posts: 7

Rep: Reputation: Disabled
Please help!!


ANY HELP WOULD BE SO VERY GREATLY APPRECIATED! THANK YOU

In the "linux1" system create a lab3 directory below your home directory. Under the lab 3 directory using the "bash shell" write a shell script for each of the following:

1. Write a script named "monthyr.bash". The script will prompt the user for the month and then the desired year to be displayed on the screen. Then your script will execute and display the desired calendar month and year on screen.

2. Write a script named "dusage.bash" . The script will prompt for the user’s login or user name and then display the amount of diskspace being used by the user.

3. Write a script "total.bash" that will calculate the total amount purchased based on the number of units purchased @ $10 each.

4. Write a shell script named “loguser.bash”. Upon execution the script will wait 5 seconds and then display output as to whether the user “wmorris” is logged in with a session.


10 Bonus Points:

Write a script named “menu.bash” that will prompt the user for a selection of items. The menu should display the as following items for the user and execute each item:



Main Menu

1. Mail
2. Vi
3. Directory Listing
4. Exit

PLEASE HELP ME IN ANY WAY. I WILL PAY YOU...IM NOT ONLY DOING THIS FOR MYSELF BUT MY DAUGHTER...GOING THRU A DIVORCE, WORKING A FULL TIME JOB AND GOING TO SCHOOL IS ABOUT TO KILL ME.
 
Old 11-11-2013, 01:02 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

people here are more than willing to help you learn, but we won't do your homework for you. If that is what you want, then please look elsewhere. Otherwise please post back again and explain what you have tried and where you are stuck.

Regards,

Evo2.
 
Old 11-11-2013, 01:07 AM   #3
HeLpInLiNuX
LQ Newbie
 
Registered: Nov 2013
Posts: 7

Original Poster
Rep: Reputation: Disabled
I honestly dont know where to start....i have created a directory called lab 3 and then im stuck
if i had an example i could maybe go from there.....

---------- Post added 11-11-13 at 01:08 AM ----------

I think i open the vi editor and then type
/bin/bash ??
 
Old 11-11-2013, 01:13 AM   #4
k3lt01
Senior Member
 
Registered: Feb 2011
Location: Australia
Distribution: Debian Wheezy, Jessie, Sid/Experimental, playing with LFS.
Posts: 2,900

Rep: Reputation: 637Reputation: 637Reputation: 637Reputation: 637Reputation: 637Reputation: 637
Have you read your unit notes and lecture materials?
 
Old 11-11-2013, 01:14 AM   #5
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

a shell script at its most basic is really just a text file with a list of commands: just like the commands you can directly enter in the terminal. Therefore you need to workout what commands need to be run to do each task, and enter them into a text files using a program called a "text editor". Do you have any reference material? For example, something that tells you how to use a text editor? That would be your starting point. Once you have that we can help you work through the questions.

Evo2.
 
Old 11-11-2013, 01:15 AM   #6
HeLpInLiNuX
LQ Newbie
 
Registered: Nov 2013
Posts: 7

Original Poster
Rep: Reputation: Disabled
I have a book and have read...i attend every class and take notes but the professor i have is rated the worst at my school....
 
Old 11-11-2013, 01:25 AM   #7
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

yes you can use the vi editor if you are comfortable with that.

Given that you don't seem to have absorbed much from your class I think a good place for you need to start is by following one of the many online bash scripting tutorials. I don't have a specific recommendation but your favourite search engine will help.

To write the first script you need to learn about assigning a value to a variable using the "read" command and about the "cal" command.

Evo2.
 
Old 11-11-2013, 01:31 AM   #8
HeLpInLiNuX
LQ Newbie
 
Registered: Nov 2013
Posts: 7

Original Poster
Rep: Reputation: Disabled
can u give me an example of one
 
Old 11-11-2013, 01:37 AM   #9
k3lt01
Senior Member
 
Registered: Feb 2011
Location: Australia
Distribution: Debian Wheezy, Jessie, Sid/Experimental, playing with LFS.
Posts: 2,900

Rep: Reputation: 637Reputation: 637Reputation: 637Reputation: 637Reputation: 637Reputation: 637
Quote:
Originally Posted by HeLpInLiNuX View Post
I have a book and have read...i attend every class and take notes but the professor i have is rated the worst at my school....
Not trying to sound harsh but comments about people we do not know and who cannot defend themselves aren't helpful.

Having read a few of your other threads I think you need to consider if continuing with this course at this time is worthwhile. Instead of getting worked up over this course it may be better to concentrate on matters closer to home and when they are finalised return to the course so you can concentrate on it properly.
 
Old 11-11-2013, 01:49 AM   #10
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

TLDP is often a good place to start.

http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html

Evo2.
 
Old 11-11-2013, 04:55 AM   #11
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,070

Rep: Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897
Quote:
Originally Posted by HeLpInLiNuX View Post

PLEASE HELP ME IN ANY WAY. I WILL PAY YOU.
I doubt that this is the kind of help that you want, but you certainly will not pay me. Anyway, what I will do for you is re-phrase the questions that you are being asked, so that it is clear what you need to achieve the objectives.

Quote:
1. Write a script named "monthyr.bash". The script will prompt the user for the month and then the desired year to be displayed on the screen. Then your script will execute and display the desired calendar month and year on screen.
As has already been stated, a script is merely a list of the commands that you would use, at the command line, in order to achieve a task. so, you have to know what commands you might use, at the command line, to achieve this.

(One tip: if you only know one command, it ought to be the 'man' command. One variant, 'man -k' (or, equivalently, 'apropos') will return all system commands that concern a particular subject (more technically, will return a list of the commands which have the given word in their brief description, along with the brief description).

So, while you might think of writing your own calendar program, a better thought might be to have a look at whether there is a calendar program on the system that you can use. This should give you a hanful of 'hits' of which one or two might be more appropriate than others. now one of the less useful 'hits', in this context would be to 'orage' (which may or may not be installed on your system, but just as an example...), so, to prove this, you would type 'man orage', and you'd find out that orage is a graphical application, which you don't want.

Quote:
2. Write a script named "dusage.bash" .
Find a system program that gives you info about disk usage. You'll find at least a couple, using the method above. If, for example, you choose 'man -k usage' you'll get more info than you want, and so 'man -k usage | grep -i disk' might be preferred.

Is there something that gives you the info that you need, even if you get too much info (hint: yes)? could you then take that 'too extensive' output and pipe it through 'grep', in exactly the way that the man output above has been piped through grep to get something more useful (hint: yes)?

Quote:
3. Write a script "total.bash" that will calculate the total amount purchased based on the number of units purchased @ $10 each.
This question seems to ask whether you can multiply something by 10 in a script. The answer should be yes, but you'll need to look for some kind of calculator (see method above). And you'll have to tell the calculator the number (presumed integer) of items, multiply and ten. You'll need the man page for that.

I'm bored now, but, if you want further help, you'll want to show what you've tried (in code tags), and what happened that you thought was wrong. There is a very limited extent that people will tell you the answers, but you might get a shove in the right direction, if you have tried and are making an obvious oversight.
 
Old 11-11-2013, 01:45 PM   #12
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
Quote:
Write a script named "monthyr.bash".
also just how OLD is this text book you are using
that should be "monthyr.sh"
.sh and not the older form .bash

WE WILL NOT do your homework

BUT

we can maybe help

just REMEMBER that a shell script ALWAYS starts with the "shebang"

Code:
#!/bin/sh
--- the code in the script goes here
 
Old 11-12-2013, 05:13 PM   #13
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: Slackware®
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Moderator Response

Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate of http://www.linuxquestions.org/questi...5/#post5062263

Please continue in the original thread.
 
  


Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration