Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

SnowLeopard2008

macrumors 604
Original poster
Jul 4, 2008
6,772
19
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:

#!/bin/ksh
# 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?"
fi


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.
 
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!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.