简体   繁体   中英

How to run shell script from a shell script without terminating it

I am working on a shell script which will install Debian packages for me, copy config files etc.

The problem is that when i try to execute external script, the parent script gets terminated, i have a script like this:

# changing shell

chsh -s $(which zsh)

# installing oh-my-zsh

sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my- 
zsh/master/tools/install.sh -O -)"

# copying zsh config file

rsync -a .zshrc ~/

My script terminates after running second step.

Thank you

I think you need something like this

sh -c "sleep 3" &
echo "We are waiting"
wait

Here you can check what the wait does https://www.gnu.org/software/bash/manual/html_node/Job-Control-Builtins.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM