Today (Saturday) We will make some minor tuning adjustments to MySQL.

You may experience 2 up to 10 seconds "glitch time" when we restart MySQL. We expect to make these adjustments around 1AM Eastern Daylight Saving Time (EDT) US.


How to continue shell script after exit 0?


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
How to continue shell script after exit 0?

Hi,
I am writing a shell script where I am sourcing other shell script in that script I have mention exit 0 due to that it is not continue the first script. Except doing any changes to source script is there any way I can continue the my first script.
# 2  
When you source another script, you can think of it as replacing your script in memory. The only way to miss the exit 0 is to remove it.
you can do this and NOT source it:

Assuming you cannot change the other script the best option is to run it as a child process.
Warning: if you need to use any of the variables created/changed in the other script this will not work for you. Only sourcing will work.
example:
Code:
#myscript
/path/to/other/script.sh &
wait
# now continue myscript code here

# 3  
Backgrounding might give you further problems.
You can try the same in the foreground:
Code:
# this is your shell script
(
# this is a copy of your shell script that inherits all variables and functions
. your_source_script
# this is not reached if there was an exit
)
# the copy has ended; any variables and functions are not copied back i.e. lost
echo "$0 continues"

# 4  
If you are able to change the script that is sourced, changing exit for return could provide better results if the exit is within a function.

Can you share with us some information about the sourced content? If it's just setting up functions, then stop it doing an exit at all. In fact, stop it doing an exit at all unless there is an error.



Thanks, in advance,
Robin
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Need a exit from sftp if its ask for password and continue to run remaining part of script.
ketanraut
Hi I am checking status of sftp in Health check script, sftp command is used to connect the server with secure RSA key, which is successfully get connected most of the time but in some case if RSA key ask for password then I need to exit sftp command after few second and continue to run...... UNIX for Advanced & Expert Users
1
UNIX for Advanced & Expert Users
Exit a shell script
Phuti
Hi Guys, How can I exit from the shell script if a condition is not met? Thanks in advance...... Shell Programming and Scripting
2
Shell Programming and Scripting
how to continue shell script execution process without control going to pompt?
vadlamudy
Hi Friends, Iam invoking another shell script to create B2k_session_id from my shell script.It is properly creating B2k_session_id and after creation control is coming out from the script and going to command prompt.The lines which are after the exectrusteduser.com sh.com are not executing..may...... Shell Programming and Scripting
5
Shell Programming and Scripting
Continue an instruction on more than one line in a script shell ?
shadok
Hello, I have a very long instruction to write, but, for lisibility reasons, I would like to cut it on more than one line and comment each lines. is it possible ? thanks :b:... Shell Programming and Scripting
1
Shell Programming and Scripting
call b.sh from a.sh, and continue to a.sh after use exit 0 from b.sh
ctuncer
Hi, I have two sh file. a.sh and b.sh b.sh is command and used by other sh's. I want to add below line to b.sh. When it is done with b.sh I want to continue to process a.sh. But when I use exit 0 in b.sh it is exit from b.sh and a.sh How can I make it to continue to process? a.sh ...... Shell Programming and Scripting
2
Shell Programming and Scripting

Featured Tech Videos