Solved

unix exit command question.

Posted on 2001-07-24
5
317 Views
Last Modified: 2012-05-04
I'm working on a script and one of the commands is:
E.   Exit from UNIX

I have this for the command:
E)
 echo "Do you want to exit UNIX"
  set reply = $<
  if ($reply == 'y') then
  exit
  if ($reply == 'n') then
  echo "Hit <ENTER> to continue:  \c"

when I run the script I get this error:

menu[5]: 0403-057 Syntax error at line 83 : `then' is not expected.

How do I get this command to work.
Thanks in advance
0
Comment
Question by:scottkey81
  • 3
5 Comments
 
LVL 6

Expert Comment

by:bira
ID: 6314585
#!/bin/ksh
 echo "Do you want to exit UNIX"
 read reply
 if [ $reply = 'y' ]; then
       exit
 fi
 if [ $reply = 'n' ]; then
 echo "Hit <ENTER> to continue:  \c"
 read
 fi
0
 
LVL 11

Expert Comment

by:griessh
ID: 6314589
From your snippet I would suggest you are missing the
#!/bin/csh
statement at the beginnig of your script (to start a new cshell).
Further you will get errors, because each if has to be closed by a 'fi' statement.

Good Luck
======
Werner
0
 
LVL 6

Expert Comment

by:bira
ID: 6314612
0
 
LVL 6

Accepted Solution

by:
bira earned 50 total points
ID: 6314613
If you decide to use it in ksh, and your intention is
to terminate the Unix session when y entered, here goes a
new version:

 #!/bin/ksh
 echo "Do you want to exit UNIX"
 read reply
 if [ $reply = 'y' ]; then
       logout
 fi
 if [ $reply = 'n' ]; then
 echo "Hit <ENTER> to continue:  \c"
 read
 fi
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6314728
griessh, if you suggest csh, then te if statement must be terminated with endif. fi is sh (ksh, etc.) syntax.

bira, logout does not work from within a script in this way.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now