1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

shell scripts in UNIX

Discussion in 'Linux / Unix Discussion' started by cf2swa, Mar 25, 2006.

  1. cf2swa

    cf2swa New Member

    7
    0
    8
    Hi, I was just wondering if anyone could give any tips on how to create a couple of shell scripts in UNIX?

    Mainly for the following functions:

    command & Description

    back<object>
    This command closes
    the current open
    directory, and goes
    back up to the previous
    directory

    find<flag><string> This command searches
    for a specified string
    according to the flags
    given:
    -f searches a directory
    for a file which matches
    string
    -s searches files in the
    current directory, for
    occurrences of that
    string

    daytopayday This command calc's
    out the days remaining
    in the month tip payday
    - assumed to be the
    last day of each month

    income<no.students> This utility calc's the
    revenue generated per
    class by multiplying the
    num of students by the
    annual fee
    - annual fee should be
    inherited by the script

    Any help would be greatly appreciated.

    Sarah.
     
    WIP: BSc Computing
  2. simongrahamuk
    Honorary Member

    simongrahamuk Hmmmmmmm?

    6,199
    125
    199
    Where's that Harry when you need him........
     
  3. hbroomhall

    hbroomhall Petabyte Poster Gold Member

    6,623
    115
    224
    Doing my weekly shopping! :biggrin

    Looking at the original question - this looks very much like a class assignment question - few in the 'real' world would want such scripts.

    If this is the case then my view is that this place doesn't exist to do other people's homework!

    I'll give some pointers though:

    "back" This makes no sense, as directories aren't 'open' when you are at the shell prompt - so can't be 'closed'. So either there is an environment we aren't being told about, or someone is confused. Either way 'cd' is probably going to figure somewhere there.

    "find" This is going to cause confusion on a normal shell prompt, because the two real commands that will be used here are 'find' and 'grep'.

    "daytopayday" will probably be using 'date'

    "income" will probably depend on the shell in use - some can do arithmetic - others can't.

    So how about introducing yourself and say what this is about?

    Harry.
     
    Certifications: ECDL A+ Network+ i-Net+
    WIP: Server+
  4. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    I agree with Harry.
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1
  5. simongrahamuk
    Honorary Member

    simongrahamuk Hmmmmmmm?

    6,199
    125
    199
    Online I hope! :biggrin

    :offtopic
     
  6. cf2swa

    cf2swa New Member

    7
    0
    8
    Hi sorry, I have been having a few problems with my uni assignment for Networking and my dad usually uses this forum and said someone may be able to give me a few pointer - not do my homework for me!

    This shell i am using is korn and the back function does use the cd .. command within it - I have already figured that out i just wasn't sure how you manipulate the directory once it has been passed to the script.

    It is ok if no help can be given to me as you obviously think i am cheating, I will just try and find a book or website that will help instead.

    Thanks
    Sarah
     
    WIP: BSc Computing
  7. hbroomhall

    hbroomhall Petabyte Poster Gold Member

    6,623
    115
    224
    Well - just to leap in with a fairly obvious assignment and not give any background made it sound as if you wanted it written for you - hence my comments. I've seen many requests that are basicaly just that on the 'net.

    On the 'back' command - there has to be something else involved - the question as written makes no sense otherwise. It says 'back up'. That could either mean up a level, where the passed 'object' would have no meaning, or that there is some other unmentioned object involved - such as a stack.

    I've never used korn shell - so don't know what is incorporated in that.

    Harry.
     
    Certifications: ECDL A+ Network+ i-Net+
    WIP: Server+
  8. cf2swa

    cf2swa New Member

    7
    0
    8
    Ok well thanks for your help but i think i am going to have to get extra help from my lecturer as i have no idea what the object would be that needs to be passed in the back script.

    Thanks very much.
    sarah
     
    WIP: BSc Computing
  9. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    I made the same assessment Harry did for the same reasons. If a person is around internet forums enough you see many requests for help that are nothing but requests asking someone online to do homework assignments because the poster either doesn't have a clue, or they are just too lazy to do the work. The way you worded your post looked like one of those posts. Also, the lack of information provided made it look like a clueless student wanting homework done for them.
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1
  10. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    I'm also not a korn shell user, but I would imagine that it has something similar to pushd and popd as that might be what your prof was asking for. http://www.faqs.org/docs/bashman/bashref_73.html

    Here is an online Korn reference that will probably be of great help.
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1
  11. cf2swa

    cf2swa New Member

    7
    0
    8
    Thanks ffreeloader I looked at the second list you posted and it looks ok at first glance, going to study it more now.

    I am a student who hasnt got a clue ha ha.

    Thanks for your help tho.

    Sarah
     
    WIP: BSc Computing
  12. cf2swa

    cf2swa New Member

    7
    0
    8
    Plus never been on a forum before and didn;t know how to start. Probs just get a book out the library or something.
     
    WIP: BSc Computing
  13. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    Learning to use the forums is like learning to use Linux: just do it till you get good at it.
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1
  14. hbroomhall

    hbroomhall Petabyte Poster Gold Member

    6,623
    115
    224
    Looking at the ksh docs seems to suggest that pushd and popd are not builtins! :eek:

    Harry.
     
    Certifications: ECDL A+ Network+ i-Net+
    WIP: Server+
  15. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    I learned that from the link I gave and it surprised me too as that functionality is something that even the Windows cmd prompt has, however, with a little searching in the link I gave a person can find an example that covers the same functionality.
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1
  16. hbroomhall

    hbroomhall Petabyte Poster Gold Member

    6,623
    115
    224
    Nope - to get first-class meat I go to a local 'real' butcher!

    Hary.
     
    Certifications: ECDL A+ Network+ i-Net+
    WIP: Server+

Share This Page

Loading...