commands for sh

commands for sh

Post by Claudio Roch » Thu, 16 Nov 2000 04:00:00



Hi Everybody,

Why this does not work using 3 option?

.
. my menu with option "e" to exit.
.
read ANS
ANS=${ANS:-e}
case ANS in
       e|exit|EXIT) exit;; ...

...If I use with 2 options only like this:  e|exit) exit;;    it works fine.

Also.
Is there any command to make the word to Blink, Bold or any other special
effect.

FYI I'm using sh

Thanks
Claudio Rocha

 
 
 

commands for sh

Post by Glenn Wes » Thu, 16 Nov 2000 04:00:00




Quote:> Hi Everybody,

> Why this does not work using 3 option?

> .
> . my menu with option "e" to exit.
> .
> read ANS
> ANS=${ANS:-e}
> case ANS in
>        e|exit|EXIT) exit;; ...

> ...If I use with 2 options only like this:  e|exit) exit;;    it
works fine.

> Also.
> Is there any command to make the word to Blink, Bold or any other
special
> effect.

> FYI I'm using sh

This seems to work for me:

$ a=${a:-e}
$ echo $a
e
$ case $a in

Quote:> e|exit|EXIT) echo here;;
> esac

here

I assume that 'case ANS in' was a typo in your message since it should
be 'case $ANS in'.

Look at tput for outputting terminal independent sequences of special
characters.  For instance:

tput smso;echo Hey;tput rmso

HTH...

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

commands for sh

Post by Lee Mille » Thu, 16 Nov 2000 04:00:00



> Is there any command to make the word to Blink, Bold or any other special
> effect.

yes, but your terminal may not support it

                 on           off
blink          - tput blink  
bold           - tput bold
italics        - tput sitm    tput ritm
reverse        - tput rev
stand out      - tput smso    tput rmso
underline      - tput smul    tput rmul
back to normal - tput sgr0

see the tput and terminfo man pages.

 
 
 

commands for sh

Post by Chris F.A. Johns » Fri, 17 Nov 2000 04:00:00


: Hi Everybody,

: Why this does not work using 3 option?

: .
: . my menu with option "e" to exit.
: .
: read ANS
: ANS=${ANS:-e}
: case ANS in
:        e|exit|EXIT) exit;; ...

: ...If I use with 2 options only like this:  e|exit) exit;;    it works fine.

It shouldn't work with two options.

Change "case ANS in" to "case $ANS in" and it should work with any number of
options.

: Also.
: Is there any command to make the word to Blink, Bold or any other special
: effect.

: FYI I'm using sh

: Thanks
: Claudio Rocha

--
        Chris F.A. Johnson

        -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
               Everything in moderation - including moderation  

 
 
 

1. killing command for sh -c command

Probably, it is.  Still, it does not always work because some
shells make the last command in a pipeline the parent of all other
commands in the pipeline (so, it won't be your shell).  Also, shells
can be nested...  To really handle all cases, you would need to trace
the ancestors all the way up to 1 (init) and kill all processes that
have your shell as one of the ancestors.  BTW, this would kill daemons
too...

You can put the shell in a process group by itself via setpgrp(2)
and then use killpg(2) to kill the whole group.  Of course, this
only works if the shell does not change process group, which it
usually does.  FreeBSD sh does not change process group for commands
in backticks, so you may try to enclose the command in $()--but
that messes up the output and does not handle nested shells.

Still another way is to mess with sessions/terminals.  It's a lot
like writing your own shell, though.

That is, decide what you want to accomplish.  If you need a more
or less fool-proof solution that is more or less portable, go with
your original approach.  If you are willing to restrict users in
that they don't launch daemons from your program, and you need a
good fool-proof solution, go with my first suggestion.  If you need
security, do not let users type in arbitrary shell commands in the
first place.

--
Drive^H^Hnk safely!
Alex Verstak                 averstak at vt dot edu
1078 Ambler Johnston East             Virginia Tech
Blacksburg, VA 24060-0022       Tel. (540) 232-1389

2. Mandrake doesn't recognize my Linksys 10MB Ethernet

3. DOSKEY like command line (sh and csh)

4. ReiserFS partition messed up

5. if command in sh.

6. Newbie - Parition Sizes

7. How to get the return-code from a rsh'd command (in sh)

8. Kernel problem with IPC msgsend.

9. How to get the return value of a command in sh?

10. recall last command on sh ( bourne )

11. bug in read command in sh under OSF1 V3.0

12. Get the exit value in a piped command (/bin/sh)

13. Execute a sh script under perl and sh: sh script; perl script?