Pause before exit


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Pause before exit
# 1  
Old 11-20-2014
Pause before exit

Code:
 6) printf "\n GoodBye! \n\n"; exit ;;

I am trying modify the above command to pause a couple of seconds before exiting, so a message can be displayed. Thank you Smilie.
# 2  
Old 11-20-2014
Hi,

Quick way is;

Code:
6) printf "\n GoodBye! \n\n"; sleep 2 ; exit ;;

Regards

Dave
# 3  
Old 11-20-2014
It does'nt pause long enough to read the message. Thanks.
# 4  
Old 11-20-2014
Hi,

Increas the sleep in seconds until it does.

Regards

Dave
# 5  
Old 11-20-2014
Hi

You could also put a trap in your script which will catch the EXIT signal (0), and wait for the [enter] key:
Code:
trap 'printf "\n GoodBye! \n\n"; read n' 0

or just wait for sleep to time out
Code:
trap 'printf "\n GoodBye! \n\n"; sleep 6' 0

# 6  
Old 11-20-2014
Slightly different approach giving a 5 second delay with keyboard override:-
Code:
 6) printf "\n GoodBye! \n\n"; read -n1 -s -t5; exit ;;

# 7  
Old 11-20-2014
I'm missing the point of this thread. Exiting a shell script doesn't clear the screen. If you don't want to clear the screen for a few seconds after the script exits, why are you clearing the screen after your script exits???
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to pause process running under nohup?

Hi ALL, Is there any way to pause a running process under nohup ? I have fired a build commands with required flags under nohup as below. now how can I pause the started build process. nohup make DEVICE=ap DEBUG=1 & I understand we can use ctrl + z to pause a foreground process... (3 Replies)
Discussion started by: useless79
3 Replies

2. Shell Programming and Scripting

How to pause a shell script

Hi, I've written a shell script to take photos with my camera. After every picture taken, the picture is transmitted to the computer via usb and then deleted on the camera. But sometimes there's an error and the picture is not deleted and so, after a certain time, the camera chip will be... (4 Replies)
Discussion started by: McLennon
4 Replies

3. AIX

How to pause a while loop while reading from a file

Hi, I am building a script to grep for a string in all the files from a folder and display the results. I am reading the files one by one by placing the names in other file using while loop my code is as below while read inp do chk=`grep -c "$str" $pth/$inp` ... (2 Replies)
Discussion started by: sekhar gajjala
2 Replies

4. Shell Programming and Scripting

Script Pause Until Rsync Is Done Transferring

Alright, I have this script that pulls files from a few locations, process those files, creates a zip file, rsync's it and then removes everything. The problem that I'm having is that I do not know how large the rsync'ed zip file is going to be. Right now I'm using a sleep command before I... (4 Replies)
Discussion started by: droppedonjapan
4 Replies

5. HP-UX

Any Way to pause/unpause system execution in HP-UX 11.11 and 11.23?

This may seem like an odd question, but I've heard that on old Alpha servers running OpenVMS, you could pause the system so that the OS is essentially suspended for a small period of time, then unpause it and it would pick up where it left off. During the pause, all CPU cycles would be halted, all... (3 Replies)
Discussion started by: deckard
3 Replies

6. UNIX for Dummies Questions & Answers

pause() problems

well is gets stuck and i dont know why....... pid=fork(); if(pid==0) { pause(); write(1,"child",5); exit(0); } else { sleep(1); kill(pid,SIGCONT); write(1,"parent",5); wait(0); } all=1; (1 Reply)
Discussion started by: IdleProc
1 Replies

7. UNIX for Dummies Questions & Answers

pause needed for corn shell

I need a user pause for a script file, like the pause command in dos. please help I thought it was the corn shell it is csh. (7 Replies)
Discussion started by: dennysavard
7 Replies

8. Programming

pause? where art thou?

ok, im somewhat of an advanced programmer for the windows-side of C/C++, and the system command to pause the console is 'system("pause");'.... i just recently transfered over to Slackware 3.3 (yes, its old, but i <3 text), and pause is not the command for pausing the command line. is there any... (3 Replies)
Discussion started by: 01000101
3 Replies

9. UNIX for Dummies Questions & Answers

how to pause another process?

I guess I posted in wrong forum before. How do I pause another process and then restart it on linux? The other process doesn't listen for anything. Thanks for any help you can offer. Dane :confused: (1 Reply)
Discussion started by: daneensign
1 Replies

10. UNIX for Dummies Questions & Answers

Where can I find a list of exit codes? (Exit code 64)

I'm receiving an exit code 64 in our batch scheduler (BMC product control-m) executing a PERL script on UX-HP. Can you tell me where I can find a list of exit codes and their meaning. I'm assuming the exit code is from the Unix operating system not PERL. (3 Replies)
Discussion started by: jkuchar747
3 Replies
Login or Register to Ask a Question