Case Question

Case Question

Post by R. Espinos » Thu, 04 May 2000 04:00:00



Hi,

How do I make the cursor stay on the same line as my prompt?

ie:     Enter option: _

rather than:

        Enter option:
        _

I am using CASE...script below:

#!/usr/bin/ksh

clear
option=0
while [ $option -ne 4 ]

do
clear
        echo "1. selection 1          2. seleciton 2"
        echo "3. selection 3          4. QUIT"
        echo

        echo Enter option:
        read option
        case $option in

                1)
                        /home/bin/expect/xb1.exp
                        ;;

                2)      /home/bin/expect/xb2.exp
                        ;;

                3)      /home/bin/expect/xv1.exp
                        ;;

                4)      echo CIAO!!!!!
                        ;;
        esac
done

 
 
 

Case Question

Post by David Hasset » Thu, 04 May 2000 04:00:00



> Hi,

> How do I make the cursor stay on the same line as my prompt?

> ie:     Enter option: _

> rather than:

>         Enter option:
>         _

  echo -n "Enter option: "

Dave. :-)

 
 
 

Case Question

Post by James A. William » Thu, 04 May 2000 04:00:00


echo "Please enter your choice: \c"
 
 
 

Case Question

Post by bk.. » Thu, 04 May 2000 04:00:00



>Hi,
>How do I make the cursor stay on the same line as my prompt?
>ie:     Enter option: _
>rather than:
>        Enter option:
>        _

echo -n "Enter option:"

demo:
/home/bkaster$echo -n test
test/home/bkaster$          

[...]

 
 
 

Case Question

Post by R. Espinos » Thu, 04 May 2000 04:00:00


hmmm...didnt work........but James A. Williams suggestion did!

<snip>

echo "Please enter your choice: \c"

<snip>

thanks for the help!



> > Hi,

> > How do I make the cursor stay on the same line as my prompt?

> > ie:     Enter option: _

> > rather than:

> >         Enter option:
> >         _

>   echo -n "Enter option: "

> Dave. :-)

 
 
 

Case Question

Post by R. Espinos » Thu, 04 May 2000 04:00:00


hmmm...didnt work........but James A. Williams suggestion did!

<snip>

echo "Please enter your choice: \c"

<snip>

thanks for the help!



> >Hi,

> >How do I make the cursor stay on the same line as my prompt?

> >ie:     Enter option: _

> >rather than:

> >        Enter option:
> >        _

> echo -n "Enter option:"

> demo:
> /home/bkaster$echo -n test
> test/home/bkaster$

> [...]

 
 
 

Case Question

Post by R. Espinos » Thu, 04 May 2000 04:00:00


WORKS!!! WICKED!!!!

tanks!



Quote:> echo "Please enter your choice: \c"

 
 
 

Case Question

Post by bk.. » Thu, 04 May 2000 04:00:00



>hmmm...didnt work........but James A. Williams suggestion did!
><snip>
>echo "Please enter your choice: \c"
><snip>

/home/bkaster$ksh
$ echo -n "test"
test$ echo "test\c"
test$ echo test
test
$  

So for me they seem equivalent.  I wonder what is happening.

Quote:>thanks for the help!

welcome.

bkasp


[...]
>> echo -n "Enter option:"

[...]
 
 
 

Case Question

Post by Matthew Land » Thu, 04 May 2000 04:00:00



> /home/bkaster$ksh
> $ echo -n "test"
> test$ echo "test\c"
> test$ echo test
> test
> $

> So for me they seem equivalent.  I wonder what is happening.

Some unicies' shells don't support the -n for echo.  On my AIX 4.3.3
box:

$ echo -n "test"
-n test
$ echo "test\c"
test$ echo test
test
$

 - Matt

--
_______________________________________________________________________

   << Comments, views, and opinions are mine alone, not IBM's. >>

 
 
 

Case Question

Post by Eric Amic » Thu, 04 May 2000 04:00:00



> $ echo -n "test"
> test$ echo "test\c"
> test$ echo test
> test
> $  
> So for me they seem equivalent.  I wonder what is happening.

It depends on the shell being used, whether the shell has echo as a
built-in, and the implementation of the external echo command if echo is
not a shell built-in.

--
Eric Amick
Columbia, MD

 
 
 

Case Question

Post by Dan Merc » Thu, 04 May 2000 04:00:00




> Hi,

> How do I make the cursor stay on the same line as my prompt?

> ie:     Enter option: _

> rather than:

>         Enter option:
>         _

> I am using CASE...script below:

> #!/usr/bin/ksh

> clear
> option=0
> while [ $option -ne 4 ]

> do
> clear
>         echo "1. selection 1          2. seleciton 2"
>         echo "3. selection 3          4. QUIT"
>         echo

>         echo Enter option:
>         read option

Since you are using ksh,  I will give you a ksh answer,  not the
bash (incorrect) and bourne answers you received:

          read option?"Enter option: "

read and prompt all in one operation.

For general knowledge,  use of echo in ksh is deprecated.  Use print instead:

   print -n "Enter option: "

--
Dan Mercer

- Show quoted text -

Quote:>         case $option in

>                 1)
>                         /home/bin/expect/xb1.exp
>                         ;;

>                 2)      /home/bin/expect/xb2.exp
>                         ;;

>                 3)      /home/bin/expect/xv1.exp
>                         ;;

>                 4)      echo CIAO!!!!!
>                         ;;
>         esac
> done

Opinions expressed herein are my own and may not represent those of my employer.
 
 
 

Case Question

Post by Wenzhi Lian » Fri, 05 May 2000 04:00:00



> Hi,

> How do I make the cursor stay on the same line as my prompt?

> ie:     Enter option: _

> rather than:

>         Enter option:
>         _

> I am using CASE...script below:

> #!/usr/bin/ksh

> clear
> option=0
> while [ $option -ne 4 ]

> do
> clear
>         echo "1. selection 1          2. seleciton 2"
>         echo "3. selection 3          4. QUIT"
>         echo

>         echo Enter option:
>         read option
>         case $option in

>                 1)
>                         /home/bin/expect/xb1.exp
>                         ;;

>                 2)      /home/bin/expect/xb2.exp
>                         ;;

>                 3)      /home/bin/expect/xv1.exp
>                         ;;

>                 4)      echo CIAO!!!!!
>                         ;;
>         esac
> done

There are 2 ways to achieve this, as far as i know:
1. echo with an '-n' switch
2. echo with an \a at the end
 
 
 

Case Question

Post by Dan Merc » Fri, 05 May 2000 04:00:00





>> Hi,

>> How do I make the cursor stay on the same line as my prompt?

>> ie:     Enter option: _

>> rather than:

>>         Enter option:
>>         _

>> I am using CASE...script below:

>> #!/usr/bin/ksh
>>         echo Enter option:
> There are 2 ways to achieve this, as far as i know:
> 1. echo with an '-n' switch
> 2. echo with an \a at the end

1. Not with ksh
2. you mean \c,  \a rings the bell

--
Dan Mercer

Opinions expressed herein are my own and may not represent those of my employer.

 
 
 

Case Question

Post by R. Espinos » Sat, 06 May 2000 04:00:00


BING!

\c did the trick!





> >> Hi,

> >> How do I make the cursor stay on the same line as my prompt?

> >> ie:     Enter option: _

> >> rather than:

> >>         Enter option:
> >>         _

> >> I am using CASE...script below:

> >> #!/usr/bin/ksh
> >>         echo Enter option:
> > There are 2 ways to achieve this, as far as i know:
> > 1. echo with an '-n' switch
> > 2. echo with an \a at the end

> 1. Not with ksh
> 2. you mean \c,  \a rings the bell

> --
> Dan Mercer

> Opinions expressed herein are my own and may not represent those of my
employer.

 
 
 

1. switch/case question under csh

In a switch statement under csh, I need a case that traps the [
character (among others).  However, all the case statements I have
tried yield a "Missing ]" error.  Here's what I've tried so far:

case "[":
case "\[":
case \[:
case "[[]":
case "[\[]":
case "'['":
case '[':

Does anyone know the magic incantation that quotes the [?  I need to
do the same thing with some other "trouble" characters like * and _
(underscore).

Thanks in advance for any pointers.

Cheers,
patrick
--

Network Administrator             VOICE:  (415) 321-2052
CASBS, 202 Junipero Serra Blvd.   FAX:    (415) 321-1192
Stanford, CA 94305                BEEPER: Temporarily Out of Order...

2. Speech recognition expert on linux sought

3. ftp case question

4. : Appropriate value for -xcache on 3500

5. ncpfs-2.2.0, Netware 4.11, filename case question.

6. Printing Very VERY slow!

7. another convert upper to lower case question

8. Need help setting up kernel parameters

9. ksh case question

10. ksh + case question

11. Motherboard/case question

12. Lower Case vs Upper Case - Apache Question

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