Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

unix exit command question.

Posted on 2001-07-24
5
Medium Priority
?
347 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 200 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
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.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses
Course of the Month21 days, 5 hours left to enroll

810 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