Ending a script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Ending a script
# 1  
Old 03-21-2009
Data Ending a script

Hi all,

I am trying to end a Menu script. Can people suggest various methods please?

At the moment I am doing:

Code:
quit=n
while [ "$quit" = "n" ]
do
...Code
Code
Code...
read userinput
case $userinput in
q|Q) quit=y;;
esac
done

But this doesn't seem to work every time, occasionally it will work, but sometimes I will have to enter q twice.
# 2  
Old 03-21-2009
Looks okay to me, thonly thing I might suggest is to try changing:

Code:
q|Q) quit=y;;

to

Code:
"q"|"Q") quit="y";;

?
# 3  
Old 03-22-2009
Quote:
Originally Posted by TonyFullerMalv
Looks okay to me, thonly thing I might suggest is to try changing:

Code:
q|Q) quit=y;;

to

Code:
"q"|"Q") quit="y";;

?

Why? That makes no difference.
# 4  
Old 03-22-2009
Quote:
Originally Posted by mikejreading
...
sometimes I will have to enter q twice.

Something you haven't posted is also reading the standard input.
# 5  
Old 03-22-2009
Quote:
Originally Posted by cfajohnson

Why? That makes no difference.
To ensure the shell knows absolutely for sure that it is comparing strings, clutching at straws I know but worth a try!
# 6  
Old 03-22-2009
Sometimes it works fine the way it is.. just sometimes it takes me entering Q a few times before the script will actually end.

Is there a command to force end a script? Like virtually pressing Ctrl & C?
# 7  
Old 03-22-2009
Don't post mutliple threads on same issue (you have posted another thread on "virtually" sending Ctrl+C). You should try to find the root cause i.e. why the script needs multiple input instead of funny workarounds like sending interrupt signals.

Post the entire while loop in CODE tags. As CFAJ said, most probably something other than read is waiting for standard input.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to check line end not ending with comma

I have several line in a text file. for example I like apple; I like apple I like orange; Output: I like apple I try to useif grep -q "!\;$"; then (Not work) Please use CODE tags when displaying sample input, sample output, and code segments (as required by forum rules). (1 Reply)
Discussion started by: cmdcmd
1 Replies

2. UNIX for Beginners Questions & Answers

School ending Script

Hello beautiful people, I would like to kindly ask you to help me with my school leaving project. Unfortunatelly due to family problems I felt into trouble and I am on able to finish my project due to schedule. I would like to ask you to review this script and give me any hints that you could.... (2 Replies)
Discussion started by: Cerda
2 Replies

3. Shell Programming and Scripting

Repetitive ending of script

Hi, I am quit satisfied with this scrtipt and really don't want to change anything but the end. I get a repetitve option when I want to "quit" and don't know why. What am I missing? When I press q to quit with this script, I get an EXTRA "Enter " How do I correct this so that when I press... (1 Reply)
Discussion started by: jefferj54
1 Replies

4. Shell Programming and Scripting

UNIX script abruptly ending due to ssh command

Below UNIX script abruptly ends while reading second line from file. When I comment 'ssh' command the script works as expected. I think I will have to run ssh command in a different process, but haven't got a handle yet as regards to how to do that. Any help in resolving this problem is highly... (1 Reply)
Discussion started by: jeeteshkc
1 Replies

5. Shell Programming and Scripting

sed in script creates output file ending with '?' (^M)

Hi, I'm trying to use sed within a shell script (bash, running ubuntu). The command works fine from the command line, but when I use it within the script, rather than creating a file with the name I've specified, it creates one that ends with a question mark '?' when you use ls, e.g.... (3 Replies)
Discussion started by: jennykay
3 Replies

6. Shell Programming and Scripting

Ending script at specific time.

Hello Everybody.. I've written the script that kick off through CRON job and kill itself by specific time. I've start time and end time specify in env file. i.e START_TIME=1500 (03:00 PM) END_TIME=0600 (06:00 AM) It always works good if my START_TIME is before midnight and my... (4 Replies)
Discussion started by: nirav_soni
4 Replies

7. Shell Programming and Scripting

Ending script after a specified time.

Hi All, I am having a script, which run fine. But what I want to do is that the script should run for specified time and terminate then ( say for a minute). Can somebody help me for this. I would be greatful. Thanks, Aru (8 Replies)
Discussion started by: aarora_98
8 Replies

8. UNIX for Dummies Questions & Answers

File- Ending

Hi folks! I'm new in this forum and in the UNIX-world too!! I've got a real problem: I have to read out datas like name and e-mail-adress from a Windows- Server from the active directory and put this information into a file. This file should be moved (or copied) on a Unix- Server... But I... (3 Replies)
Discussion started by: spikylina
3 Replies

9. Shell Programming and Scripting

ssh not ending (sometimes) from inside a script, why?

Okay I have this script file that runs from cron and most the time it works just find. Except every so often one of the three ssh commands I have in it just doesn't know it's done and that of course causes the whole thing to hang! The ssh command has executed. I can tell this because the command... (1 Reply)
Discussion started by: stilllooking
1 Replies

10. UNIX for Dummies Questions & Answers

Ending Mail

hello, I a problem. I would like write script in True64 Unix.see below. last testerkl | head > mailfile.asc wolteru < mailfile.asc With the "last" command I get a list when testerkl logged on. And I would like to send this to a user. But how can I write in a "ctrl.-d" and "ctrl.-c" that... (2 Replies)
Discussion started by: Peterh
2 Replies
Login or Register to Ask a Question