LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-11-2009, 11:24 PM   #1
apb1987
LQ Newbie
 
Registered: Jan 2009
Posts: 2

Rep: Reputation: 0
Smile Terminal And Script Help!!


Hi there, I'm trying to find a way to do a few scripts but I am really struggling, I have no idea where to even start, I just sit and stare at nano until it eventually beats me in our staring contest and I go to bed and worry!! I have to make a serious scripts (10 to be exact) that all accomplish different things, can someone please please please help! I'll be eternally grateful the scripts I have do are the following:

1.Motd
Write a script to display a message of the day (motd). The message should be held in a file with a known location, for ease of updating the file for many users.

2.Unindent
Reading from standard input, unindent each line and write the result to standard output. Use a parameter to control what form the indent takes. By unindenting the lines means removing the specified indent from the beginning of the line, take care only to remove one copy in the case of multiple indents.

3.Generate a sequence of numbers
Write out a sequence of page sizes for the A series of paper sizes (http://en.wikipedia.org/wiki/Paper_size). For each write out the name, width and height (e.g. A4*210*297) start at A0 and go to the size given as a parameter, so for a parameter of 8 write out the sizes A0 to A8 one per line.

4.Generate a list of pixels
Given two parameters write out the list of pixels. For parameters 2 3 the sequence is:

(0 0) (0 1) (0 2)
(1 0) (1 1) (1 2)

5.Display the first n lines of the input.
Write your own version of the head command (do not simply put a wrapper round head). The program should display the first n lines of a file where n is given as a parameter and the file read from standard input.

6.A wrapper for file operations, provides a menu and confirmation.
Write a script that provides a wrapper for file operations, deleting, renaming and moving. It should provide clear lists of actions, prompts and conformation to describe the actions it is to take.

7.Template default values
Often I need to generate a common piece of text, such as a copyright statement for a program. It has a number of values that need filling in, such as the date, version and author. Write a script to fill these values into a header comment.

/* copyright (c) <date>
* by <author>
* version <version>
* Some legal stuff about coping and as is software...
* caveat utilitor
*/
8.Version control
A simple form of version control can be done as follows. A directory is used as a store. When a file is checked into the store a version number is added to the end of the filename. For example memo.txt becomes memo.txt;1 memo.txt;2 etc. Each time the next number in the sequence is used. Two scripts are needed, one to store the next version in the store. The other script retrieves a given version number from the store.

9.Maintain a dictionary
A dictionary is a list of known spellings of words. This needs to be maintained and updated periodically. Words need to be added and the dictionary kept in the right order. Write a script to take a given word and insert it into the dictionary if it does not already exist, preserving the sorted order of the file.

10.A simple address book program.
A simple address book can be stored, one entry per line, with suitable characters separating fields (TAB or colon). A script (or scripts) manages the address book, functions include adding and deleting entries, searching for entries and displaying the entry in a more readable format than that used in the file.
Example: Alun Moon:alun.moon@northumbria.ac.uk:x7622:Pandon 125

I accept this is a Linux forum but I'm so stuck and time is running out for me! please please help!

many thanks in advance!!

--
Andy Brown
 
Old 01-12-2009, 10:21 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,919

Rep: Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689
Quote:
Originally Posted by apb1987 View Post
Hi there, I'm trying to find a way to do a few scripts but I am really struggling, I have no idea where to even start, I just sit and stare at nano until it eventually beats me in our staring contest and I go to bed and worry!! I have to make a serious scripts (10 to be exact) that all accomplish different things, can someone please please please help! I'll be eternally grateful the scripts I have do are the following:

I accept this is a Linux forum but I'm so stuck and time is running out for me! please please help!
This sounds VERY much like homework. We'll be glad to HELP you do it, so if you post what you've done already, and what error(s) you're getting, you're likely to get help.

Saying what you need to do, without showing any effort on your part, probably won't get you much. We're certainly not going to write your scripts for you.
 
Old 01-12-2009, 12:24 PM   #3
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1285Reputation: 1285Reputation: 1285Reputation: 1285Reputation: 1285Reputation: 1285Reputation: 1285Reputation: 1285Reputation: 1285
These don't look very difficult, you could write them all in about 3-4 hours or so. But it's homework so first here are some good references / tutorials:
http://tldp.org/LDP/abs/html/
http://www.grymoire.com/Unix/

Study up and come up with something, we can't write the scripts for you, it would be counter-productive for both us and you. The point is for you to learn bash, not for us to do your homework.

Oh, and don't use nano for this, use an IDE such as geany or something with syntax-highlighting, it will help a lot with any programming or scripting language.

Last edited by H_TeXMeX_H; 01-12-2009 at 12:27 PM.
 
Old 01-12-2009, 12:34 PM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
FYI---This is the kind of homework question that can really upset people. It comes across as: "I am behind on my assignments, I have not been paying attention in class---now please do my work for me."

Please tell us something about the class, what you have studied so far, etc. Before an instructor would give an assignment like this, they would expect you to know certain things.

At tldp (link in the previous post) I would start with the Bash Guide for Beginners.
 
Old 01-13-2009, 06:05 AM   #5
apb1987
LQ Newbie
 
Registered: Jan 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Sorry yeah it is my assignment to be honest, though not because I havn't been paying attention I've had bronchitis you see. Ive done message of the day, but it's a bit of a cheat, all I've done is opened the /etc/motd file into nano and then used the echo command, its the only thing I know how to do (
 
Old 01-13-2009, 08:33 AM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
If the instructor expects you to be able to write those scripts and all you know is the "echo" command, then this may not have a happy ending.

Have you looked at the links we provided, and were they helpful?

Please tell us something about the class, what you have studied so far, etc. (Second request)
 
Old 01-13-2009, 11:37 AM   #7
rizwanrafique
Member
 
Registered: Jul 2006
Distribution: Debian, Ubuntu, openSUSE, CentOS
Posts: 147

Rep: Reputation: 19
Adding what others say...

If you already have some experience of programming in any language then basic scripts (extending from your knowledge of echo and containing basic control structure) can be written by applying that logic and using bash syntax. Use tldp or google for help on bash syntax.

If you start on any of these and get stuck somewhere feel free to post the errors/issues and someone will help you out :-)
 
Old 01-13-2009, 06:59 PM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Definitely read those links. Also, re-read your class notes. Profs don't (usually!) hand out assignments that can't be done by your current point in the class.
Also, as recommended, use an editor with syntax highlighting eg vim.

Here's some more links:
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://rute.2038bug.com/index.html.gz

Then, pick one qn and try it. If you get stuck, show us your code.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
making a script that opens terminal and enter commands into that terminal Cinematography Linux - General 8 12-16-2008 11:34 AM
run a terminal from script abd_bela DamnSmallLinux 1 06-24-2008 07:18 AM
Script requires terminal freelancer42 Linux - Software 2 02-01-2007 09:09 AM
is there a script that controls what happens when you switch a terminal? Fascistchicken Linux - General 2 09-29-2004 11:11 PM
.sh script pops up terminal, but won't stay up!!! slooper Linux - Software 6 08-21-2003 10:42 AM


All times are GMT -5. The time now is 04:11 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration