UNIX Korn typeset, if loop questions

Discussion in 'Mac Programming' started by SnowLeopard2008, Apr 26, 2009.

  1. SnowLeopard2008 macrumors 604


    Jul 4, 2008
    Silicon Valley
    This is my homework, but I only need help on a few things. I'm writing a script to convert user inputted variables to all lowercase and then all uppercase. And then comparing the variables using the if loop. Here's my script:

    # He Chen
    # Assignment 10, a10b, Apr 25
    # Greet user in Korn shell

    print "Welcome, please enter your first and last name."
    read first last
    #print $first $last

    # convert names to lowercase
    set typeset -l first="$first"
    set typeset -l last="$last"
    print $first $last

    if [[ ${first1} = tom && ${last1} = jones ]] then
    print "Welcome, Tom Jones."

    # convert names to uppercase
    set typeset -u $first $last

    elif [[ ${first} != tom && ${last} != jones ]] then
    print "Are you happy today, $first $last?"

    When I execute the script, the typeset command doesn't work (see the print $first $last) and the if loops won't work. Any help? I've search my textbook, and the powerpoints from my teacher. None of which helped.

    EDIT: I'm not sure if this forum is the right place, but it's the best match for my question.
  2. LtRammstein macrumors 6502a


    Jun 20, 2006
    Denver, CO
  3. SnowLeopard2008 thread starter macrumors 604


    Jul 4, 2008
    Silicon Valley
    Thanks I got it. Just had the wrong syntax. Thanks!
  4. zmttoxics macrumors 65816


    May 20, 2008
    Welcome to KSH. Just a note for you, thats called an "if statement", there is no looping involved there. I recommend you read the differences between KSH88 and KSH93 if you are just starting scripting with KSH. 93 is more compatible with BASH scripting, while 88 is found on more "secure" / legacy systems like Solaris 8-10.

    Good luck!

Share This Page