Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Want to return to menu after an abort instead of % prompt 1

Status
Not open for further replies.

dodge20

MIS
Jan 15, 2003
1,048
US
I know very little about unix. How can I make a menu item return to the previous menu if the process is aborted? Right now it takes me all the way out to a % prompt. I am on Unix Sco 5.0.5. Other than that I don't know too much.

Dodge20
 
If by an abort, you mean a Ctrl-C, try adding the following early in your script:

stty intr "^C
 
Sorry - should have added that the ^C is generated using a ctrl-Vctrl-C sequence.
 
i use a telnet program called putty. I right click and go to interrupt process. I don't use control-C

Dodge20
 
Can you post your "menu" script?
If the menu prompts for a selection, then does an "exec" of another script, the menu script can't wait around for the secondary script to end. On the other hand, if you keep the user in a loop within the menu, and do NOT "exec" the task script, the menu should still be running when the task script ends.
 
Code:
#delimdd.pm

  echo "\nEnter the password: \n"
                read pword
cd /usr/ias/stories
word $pword.lst;

cd /usr/ias/misc/delim
vi delim"$pword";

chmod 777 delim"$pword"
delim"$pword" < /usr/ias/stories/"$pword".lst > /tmp/"$pword".1;

cd /tmp
more "$pword".1;

        isql soils - <<TEXTA
delete from iastun
where ipassword = "$pword";
load from $pword.1
insert into iastun;
TEXTA
cd /usr/ias/bin
sperform -s iastun;

  echo "\nEnter the password: \n"
                read pword
cd /usr/ias/stories
word $pword.lst;

cd /usr/ias/misc/delim
cp delimht delim"$pword";
vi delim"$pword";

chmod 777 delim"$pword"
delim"$pword" < /usr/ias/stories/"$pword".lst > /tmp/"$pword".1;

cd /tmp
more "$pword".1;

        isql soils - <<TEXTA
delete from iastun
where ipassword = "$pword";
load from $pword.1
insert into iastun;
TEXTA
cd /usr/ias/bin
sperform -s iastun


Dodge20
 
oops got some duplicate data, but you get the idea.

Dodge20
 
And where is the menu you talked about ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
sorry as you can tell I don't understand any unix and I really don't care too either.

Code:
#
# Module Name=ht.sh                     rev=1.23 on 6/28/88 21:16:36
#
# ht.sh  (IAS MAIN MENU) UNIX shell
# Copyright (C) 1985,1986  IIN, Incorporated,  Des Moines, Iowa
# All Rights Reserved
#

# this code made some weird messages in SCO Xenix
# CDB 88.05.02
# trap "echo \007" 2
#trap "echo shell aborted; exit 1" 3
#case $CLEAR in
#"")
#       CLEAR=`clear`
#       ;;
#esac

# DEFINE the shell variables needed for the menus

. /usr/ias/bin/tlset.sh

INFORMIXDIR=/usr/informix.7.2
INFORMIXSERVER=link3_se
DBPATH=/usr/ias/db

PATH=$INFORMIXDIR/bin:$PATH:/usr/ias/bin
export PATH DBPATH INFORMIXDIR INFORMIXSERVER

while :
do
DATE=`date`
cls
echo "
                       THE LINK
                    HOMETOWNERS MENU            $DATE
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

1. Prepare & Load Names(existing pwrd)  5. Print Students not in report
1a.Prepare & Load Names(new pwrd ONLY)  6. Prepare & Run Students not in Report
2. Prepare & Test Program(existing pwrd)7. Create Elec. Zone & Print for Mail
2a.Prepare & Test Program(new pwrd ONLY)8. Prepare & Release HT
3. Run HT Program
4. Check status of HT program
--------------------------------------------------------------------------------

11. Media Table        15. Delete/Load updated media zips 19. List delim files
12. Iastun Table       16.                                20. List .htrpt files
13. Hometown Table     17. Location Table                 21. Vi .aster file
14. Region Descr Table 18. Region Table

                      50.  (E)xit the IAS Production System


                       Enter the desired Function --> \c"
        read RESPONSE
        echo
        case $RESPONSE in
         1)
                cd /usr/ias/bin
                sh delimdd.pm
                echo "[Press ENTER to Continue]"
                read SOWHAT
                ;;
        1a)
                cd /usr/ias/bin
                sh delimdd2.pm
                echo "[Press ENTER to Continue]"
                ;;
         2)
                cd /usr/ias/bin
                sh htrptdd.pm
                echo "[Press ENTER to Continue]"
                read SOWHAT
                ;;
        2a)
                cd /usr/ias/bin
                sh htrptdd2.pm
                echo "[Press ENTER to Continue]"
                read SOWHAT
                ;;
         3)
                cd /usr/ias/bin
                sh ht.pm3
                echo "[Press ENTER to Continue]"
                read SOWHAT
                ;;
         4)
                cd /usr/ias/bin
                sh ht.pm3a
                echo "[Press ENTER to Continue]"
                read SOWHAT
                ;;
         5)
                cd /usr/ias/bin
                sh nprintdd.pm
                echo "[Press ENTER to Continue]"
                read SOWHAT
                ;;
         6)
                cd /usr/ias/bin
                sh viredodd.pm
                echo "[Press ENTER to Continue]"
                read SOWHAT
                ;;
         7)
                cd /usr/ias/bin
                sh regiondd.pm
                echo "[Press ENTER to Continue]"
                read SOWHAT
                ;;

         8)
                cd /usr/ias/bin
                sh elecdd.pm
                echo "[Press ENTER to Continue]"
                read SOWHAT
                ;;

        11)
                /usr/ias/bin/dupchk /usr/ias/bin/md2
                ;;
        12)
                /usr/ias/bin/dupchk /usr/ias/bin/iastun
                ;;
        13)
                /usr/ias/bin/dupchk /usr/ias/bin/ht_zips
                ;;
        14)
                /usr/ias/bin/dupchk /usr/ias/bin/whatreg
                ;;
        15)
                cd /usr/ias/bin
                sh htmdzip.pm
                ;;
        16)
                ;;
        17)
                /usr/ias/bin/dupchk /usr/ias/bin/loc
                ;;
        18)
                /usr/ias/bin/dupchk /usr/ias/bin/regtable
                ;;
        19)
                cd /usr/ias/bin
                sh htdelim.pm
                ;;
        20)
                cd /usr/ias/bin
                sh hthtrpt.pm
                ;;
        21)
                cd /usr/ias/bin
                sh aster.pm
                ;;
        50)
                cls
                exit 0
                ;;
         e)
                cls
                exit 0
                ;;
         E)
                break
                ;;
        90)
                reset
                stty echo echoe
                ;;
        99)
                sh
                ;;
        esac
        case $? in
        0|254)
                ;;
        *)
                echo 'Hit RETURN to continue'
                read OPERATOR
                cls
                ;;
        esac
done

Dodge20
 
and I really don't care too either
So, why posting in an unix forum for IT professionals ?
 
Because our unix person quit, and I must do this until we get a replacement. Sorry for offending you.

Dodge20
 
The code for handling interrupts is there - see trap statements that were commented out for some reason...

# this code made some weird messages in SCO Xenix
# CDB 88.05.02
# trap "echo \007" 2
#trap "echo shell aborted; exit 1" 3

Uncomment the two 'trap' lines and see what happens. If you get the so called weird messages, I would like to know what they are... (uncomment: edit the script and remove the '#' characters before the word trap)

Telnet "Interrupt Process" command or ctrl-C in the shell session act somewhat similar - a signal called SIGINT is sent to the process that is running in your login session. It is just a difference of who generates the signal - the shell or the telnet program.

With trap you can choose to ignore or act upon reception of a specific signal. By commenting the 'trap' lines you get the default action - all running processes are interrupted and your shell session returns to the shell prompt...



HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top