简体   繁体   中英

How does a shell script execute another shell script from within itself

My question is how does a shell script execute another shell script does it spawn in a new process? or is it executed in the same process as the script that called it? A example would be a Python script that is executed from a shell script after a condition is met also how would someone write this shell script where it would spawn the Python script and then exit itself without killing the Python script

Yes shell also will spawn new process if you invoke shell script within shell. if you want to spawn python script and exit without killing, run python in background in shell script/ or disown python process.

Python can spawn new processes and control their lives.

You can create and manage them using modules such as subprocess : " The subprocess module allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes. "

If you want to run them on other threads, you can use multiprocessing : " multiprocessing is a package that supports spawning processes using an API similar to the threading module. "

Shell scripts are something different, maybe this question (and its answers) can help you understand shell scripts launching other scripts :)

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