How can I trap a user in script <-<-<-<-<-<-<-<-

How can I trap a user in script <-<-<-<-<-<-<-<-

Post by The Only!!! Migh » Sat, 21 Jan 1995 13:11:45



Hi,
        I wrote this script, how can trap the user until
the choice is 7

----------
#! /bin/csh -f
#
# This script will let user access internet

#
#  These are the Choices
#
echo "             1. lynx \
                2. mosaic  <-<- Requires a graphics interface\
                3. gopher\
                4. ftp\
                5. telnet\
                6. archie\
                7. exit"
# Here we do the enterning
echo -n "Please Choose one from above   "
set choice="$<"

# Here we see the choices
if ("$choice" == "1" ) then
        /usr/local/bin/lynx http://www/homepage.html
endif
if ("$choice" == "2" ) then
        /usr/local/bin/mosaic http://www/homepage.html
endif
if ("$choice" == "3" ) then
        /usr/more/bin/gopher scsu.ctstateu.edu
endif
if ("$choice" == "4" ) then
        /usr/ucb/ftp
endif
if ("$choice" == "5" ) then
        /usr/ucb/telnet
endif
if ("$choice" == "6" ) then
        clear; echo "Login as archie";sleep 1; telnet ds.internic.net
endif
if ("$choice" == "7" ) then
        exit (0)
endif
----------
Any Help App...
Thanx
Bikesh
TUM

My views are my own not my employers' view, Hell they don't pay me enough.
     _|_                                                     _|_
    (___)- - - - - - - - - - - - - - - - - - - - - - - - - -(___)
     |/|            Southern Conn. State University          |/|
     |/|            Senior  System Admin. CS Dept.           |/|
     |/|            Phone (203) 392-                         |/|
     |/|    http://www.scsu-cs.ctstateu.edu:/bikesh.html     |/|

      V                                                       V  

 
 
 

How can I trap a user in script <-<-<-<-<-<-<-<-

Post by John Ellithor » Sun, 22 Jan 1995 04:07:14



Quote:> Hi, I wrote this script, how can trap the user until the choice is 7

You need to embed it into a while loop.  However, the user can still
exit the script by typing ctrl-c.

#!/bin/sh
#
# Trap user in script until option is made
#

echo "     1. lynx
        2. mosaic <-<- Requires a graphics interface
        3. gopher
        4. ftp
        5. telnet
        6. archie
        7. exit"

while true
do
 echo "Please choose one from above   "
 read choice

 case $choice in
        1) echo lynx;;
        2) echo mosaic;;
        3) echo gopher;;
        4) echo ftp;;
        5) echo telnet;;
        6) echo archie;;
        7) exit 0;;
 esac
done

Hope this helps
John
--
===============================================================================

Dept. of Physics, Rm 26-319               | Phone   : (617) 253-4028  Office
Massachusetts Institute of Technology     |           (617) 253-3072  Lab
Cambridge, MA  02139                      |           (617) 236-4910  Home
===============================================================================

 
 
 

How can I trap a user in script <-<-<-<-<-<-<-<-

Post by Jason K F » Wed, 25 Jan 1995 02:04:48



: Hi,
:       I wrote this script, how can trap the user until
: the choice is 7

: ----------
: #! /bin/csh -f
: #
: # This script will let user access internet

: #
: #  These are the Choices
: #
: echo "           1. lynx \
:               2. mosaic  <-<- Requires a graphics interface\
:               3. gopher\
:               4. ftp\
:               5. telnet\
:               6. archie\
:               7. exit"
: # Here we do the enterning
: echo -n "Please Choose one from above   "
: set choice="$<"

: # Here we see the choices
: if ("$choice" == "1" ) then
:       /usr/local/bin/lynx http://www/homepage.html
: endif
: if ("$choice" == "2" ) then
:       /usr/local/bin/mosaic http://www/homepage.html
: endif
: if ("$choice" == "3" ) then
:       /usr/more/bin/gopher scsu.ctstateu.edu
: endif
: if ("$choice" == "4" ) then
:       /usr/ucb/ftp
: endif
: if ("$choice" == "5" ) then
:       /usr/ucb/telnet
: endif
: if ("$choice" == "6" ) then
:       clear; echo "Login as archie";sleep 1; telnet ds.internic.net
: endif
: if ("$choice" == "7" ) then
:       exit (0)
: endif
: ----------
At the beginning of your script add the line:
trap "" 0 1 2 3 10 15
This will trap kill, hangup, interrupt, software termination, exit, and
quit commands.  However, if the users are crafty they will simply shell
out of ftp to get to a system prompt.

Hope this helps
JKF

 
 
 

How can I trap a user in script <-<-<-<-<-<-<-<-

Post by Emery Lapins » Wed, 25 Jan 1995 16:44:51




>: Hi,
>:   I wrote this script, how can trap the user until
>: the choice is 7

[script deleted]

Quote:>At the beginning of your script add the line:
>trap "" 0 1 2 3 10 15
>This will trap kill, hangup, interrupt, software termination, exit, and
>quit commands.  However, if the users are crafty they will simply shell
>out of ftp to get to a system prompt.

Well, I don't think bikesh was using trap in the technical sense, but
rather meaning how can he keep the user executing his script until
the user selects number 7 from the menu ("exit").

There are a few ways.  The first, and easiest (and most distressing?)
is to stick a goto in there after your big if block (or don't they
teach "goto" anymore?)  Another would be to place the whole thing
inside a while statement and set a flag to exit the loop.  And many,
many more . . .

-Emery
--
The signature virus turns good: Canter and Siegel appear to archive
all posts referring to themselves (can you say "grepping for liable cases"?).
Get revenge on the sociopathic spammers.  Fill their disk and waste their time
by including the words "Canter", "Siegel" and "Green Card" in your .signature.

 
 
 

How can I trap a user in script <-<-<-<-<-<-<-<-

Post by Dan Zepe » Sat, 28 Jan 1995 02:39:23


Emery said to use the `trap' command. That won't work because
trap is a Korn Shell command. You wrote your script in Csh.

What exactly do you mean by "trap the user". If it's what I think
you mean, "keep presenting the menu until a valid response is
given, then do something like this:

#!/bin/csh -f
set choices=0
while ( $choices < 1 || $choices > 7 )

   echo "Menu with 7 choices here, choose 1-7"
   set choices=$<

end

switch ($choices)

   case 1:
       echo "You picked 1"
   breaksw
   case 2:
      echo "You picked 2"
   breaksw
   case "3":
      echo "You picked 3"
   breaksw
   case "4":
      echo "You picked 4"
   breaksw
   case "5":
    echo "You picked 5"
    breaksw
   case "6":
      echo "You picked 6"
    breaksw
   case "7":
      echo "You picked 7"
    breaksw
endsw

Get rid of that ugly if/endif block and put it into a decent
switch.

BTW, If you are so mighty "The Only!!! Mighty", how come you can't
do a simple csh script like this? You should consider changing
your tag line until you can live up to it.

Dan

 
 
 

How can I trap a user in script <-<-<-<-<-<-<-<-

Post by Richard G. La » Sat, 11 Feb 1995 23:44:09




|> >: Hi,
|> >:     I wrote this script, how can trap the user until
|> >: the choice is 7
|> [script deleted]
|>
|> >At the beginning of your script add the line:
|> >trap "" 0 1 2 3 10 15
|> >This will trap kill, hangup, interrupt, software termination, exit, and
|> >quit commands.  However, if the users are crafty they will simply shell
|> >out of ftp to get to a system prompt.
|>

The "trap" command is a Bourne shell built-in command.  It will not work in
the C shell.  The only signal-handler in the C shell is the "onintr" command,
which will ONLY trap the INTR signal, not others.  Use the Bourne shell or
Perl for better signal handling.

|> -Emery
|> --
* snip *

Rich
--
===============================================================================
|                                                                             |
|     Richard G. Lang                      Allen-Bradley Automation Group     |
|     Systems/Network Analyst                   Highland Heights, Ohio        |

|                                                                             |
===============================================================================
    My expressed opinions are my own; ascribe them to no one else, please.

 
 
 

1. <<<<<soundconfig problem <<<<<<<

hi,
I have a PC100 m747 mainboard
with onboard SIS AGP 6326 8meg videocard
with onboard Sound 3d with sounblaster 16 and WSS support

my SIS videocard works fine
i have problems to configure the soundcard
it claims to be soundblaster compatible , but installing a
'sounblaster 16' , 'soundblaster pro' 'WSS' 'MAD16' has no effect
just "modprobe: devive is busy or not found"

--
Microsoft, just the product of a society
     that's lost it's good manners

--
Microsoft, just the product of a society
     that's lost it's good manners

--
Microsoft, just the product of a society
     that's lost it's good manners

2. TERM problem

3. I need a example of X .twmrc file PLEASE <<<<<<<<<<<<<<<<<<<<<

4. DOSEMU and raw parallel port access

5. SOLARIS 2.3 NOT getting the NAMESERVER <<<<<<<<<<<<<<<<<<<<

6. Is DNS a problem??

7. Script for makeing whole bunch of account of sol. 2.3 <<<<<<<<<<<<<<<<<

8. refresh text on a simple shell script "talk" program

9. CDE <<<<<<<<<-------------- Need Help !

10. How can grep the 8th of Field <<<<<<<<

11. CPAN question <<<<<<<

12. AUTO-REDIAL PPPGO <<<<<<<

13. I think I've found the rectum of the internet.<<<<<<<<<<<<