1. Sign-up to become a member, and most of the ads you see will disappear. It only takes 30 seconds to sign up, so join the discussion today!
    Dismiss Notice

Unix assign problem

Discussion in 'Archived Threads 2001-2004' started by Ronan, Dec 6, 2001.

  1. Ronan

    Ronan Auditioning

    Joined:
    Jul 5, 2001
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    part of my assignment is, to write a script 'C shell' to accept any user ID. containing the any of the following characters ' y r e w q s ' in any position of the user ID.

    So far I have the easy part done.

    Now I need to search the user's ID for one of the characters above and if it contains one accept the ID.

    prempt:

    onintr interrupt

    echo "Welcome to the UNIX O/S."

    set password = y

    echo -n "Enter your password: "

    set code = `head -1`

    while ("$password" != "$code")

    echo "Wrong password."

    echo -n "Enter your password again: "

    set code = `head -1`

    end

    echo "correct password"

    exit 0

    interrupt:

    echo "Do not try to terminate by pressing ^c!"

    goto prempt

    If anyone is able to sugest a solution I would be very greatful.
     
  2. Kevin P

    Kevin P Screenwriter

    Joined:
    Jan 18, 1999
    Messages:
    1,439
    Likes Received:
    0
    Trophy Points:
    0
    Replace this line:
     
  3. DonRoeber

    DonRoeber Screenwriter

    Joined:
    Feb 11, 2001
    Messages:
    1,849
    Likes Received:
    0
    Trophy Points:
    0
    Interesting script. But just for claritys sake, the shell doesn't handle user authentication.... on most systems, its handled by the 'login' program. So you'd need to rewrite the C code for the login program. Or, if your version of login supports PAM, you could probably write a PAM module, and have login use that.
     
  4. Ronan

    Ronan Auditioning

    Joined:
    Jul 5, 2001
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    Thanks Kevin it worked nicely.
    I was thinking that if I set had set six passwords = to
    = *y*
    = *r*
    = *e*
    = *w*
    = *q*
    = *s*
    and use an elseif statement.
    I know this would be longer but I never knew about globbing before. would it have worked.
    well anyway I used your code and I was as happy as larry
    many thanks[​IMG] [​IMG] [​IMG] [​IMG] [​IMG]
     
  5. Glenn L

    Glenn L Stunt Coordinator

    Joined:
    Jun 21, 1999
    Messages:
    56
    Likes Received:
    0
    Trophy Points:
    0
    (*dusts off his account*)
    The tcsh solution is nifty, but won't pass in regular csh. Use grep...
    while (echo $code | grep '[yrewqs]' >&! /dev/null)
    [​IMG]
     

Share This Page