case

case

Post by Yau L » Mon, 09 Dec 1996 04:00:00



hi, can anyone help me.  I tried to make a case script to insert in my
.login file but it didn't work.  It looks like this:

echo "Please choose:"
echo "(D)irectory  (L)ogoff  (S)hell"
read choice
case $choice in
D) ls -al;;
L) exit;;
S) cd;;

can anyone tell me what was wrong?

--
                         *******************************
                         *      Ryan Yau Lok Au        *
                         * http://www2.hawaii.edu/~yau *

                         *******************************

 
 
 

case

Post by Per Kistle » Mon, 09 Dec 1996 04:00:00


Hi Yau

The .login is for csh/tcsh, but your statement with case $....
is for sh/ksh/bash/zsh.

So if you have really csh/tcsh then it looks like:

switch ($...)
    case D:
        ls -al
        breaksw
    case L:
        exit
        breaksw
    case S:
        cd
endsw

But if you have sh or ksh then it's:

case $... in
    D)...;;
...ending in
esac
which you left out. And that would be in .profile or so.

As long as you are neither sure which shell you have or how
to write such a statement, it may be better not to
fiddle with .login anyway.

All the best, Per.

--
Per Kistler, Zuerich, Switzerland. (I love unix)

http://www.micro.biol.ethz.ch/~pkistler
----------------------------------------------------------------------

 
 
 

case

Post by Don Bla » Mon, 16 Dec 1996 04:00:00



Quote:>hi, can anyone help me.  I tried to make a case script to insert in my
>.login file but it didn't work.  It looks like this:
>echo "Please choose:"
>echo "(D)irectory  (L)ogoff  (S)hell"
>read choice
>case $choice in
>D) ls -al;;
>L) exit;;
>S) cd;;

Well, a couple of things wrong here:
a) a case needs to end with the string "esac"
b) if you're using .login then you quite likely logging
   on to csh & then `case' is not going to work as you plan.

If you really want the above menu, as given, to be called from .login
one thing you could try is putting:
         exec the_below_script's_name
as the last line in your .login (you need not exec it if you don't
really want that puzzling L option, but if you do, you'll need it for
"exit" to actually log you out)
If you had bash as your shell you could toss the top line and append
the rest to your .bash_profile  

#! /bin/sh
echo "Please choose:"
echo "(D)irectory  (L)ogoff  (S)hell"
read choice
case $choice in
D) ls -al;;
L) echo Hey you just got here! Oh, well; exit;;
S) echo hmm; cd;;
esac

 
 
 

1. How do I translate all upper case to smart mixed case?

Hi all,

I'm looking to convert all-upper case output to mixed case -- sentances
start with capitals, all others are lowercase.  Here's the rules
I need to follow:

After 1 period, next non-whitespace character is capitalized.
No case switching after 2 or more periods... to allow for elipsis.
After 1 or more CR, next non-whitespace character is capitalized.

My knowledge ends with the command "tr /A-Z/ /a-z/" which of course
is rather less smart than I need.

Can the above be done reasonably simply?

Mucho thanks,
Nate.

--

Nathan Gasser       ><>        

2. Need Help restoring a file!!!!

3. case-insensitive file system with Apache being case-sensitive.

4. Internet Connection Sharing?

5. upper case vs lower case ****newbie*****

6. Missing /etc/lp/filter.table (Solaris 2.6)

7. lower case <-> upper case

8. Trouble doing PPP from NT to Solaris

9. upper case vs lower case account names

10. Script to Convert Upper Case Filenames to Lower Case

11. change lower case word to upper case using sed?

12. Convert upper case to lower case

13. Converting from lower case to upper case using sed