I am a newbie to programming on the unix Command Line*, and was wondering how you take what a user types in and convert it into a variable to be used in the script?
*I always used it for file editing, but nothing more. Then I began to use BBedit.
I am a newbie to programming on the unix Command Line*, and was wondering how you take what a user types in and convert it into a variable to be used in the script?
*I always used it for file editing, but nothing more. Then I began to use BBedit.
#!/bin/ksh
echo "Give me your best shot: "
read bestshot
echo "The user's best shot was ${bestshot}."
Fancy UNIX shell programming trick:
printf "Hit me: "
stty raw
hit=`dd if=/dev/tty bs=1 count=1 2>/dev/null`
stty cooked
echo "User hit a $hit character!"
-mschwage