In general it is not a bad thing to create another process from your own process.
People do this constantly on the bash.
However, one always should ask oneself what is the best environment to do the task you need to do.
For instance I could easily call a python script to cut
(the linux tool) a column from a file. However, the overhead to first open the python interpreter, then save the output from cut
, and then save that again is possibly higher than checking how to use the bash-tool with man
.
However, collecting output from another "serious" program to do further calculations on that output, yes, you can do that nicely with subprocesses (though I would opt for storing that output in a file and then just read in the file if I need to rerun my script).
And this is where launching a subprocess may get tricky: depending on how you open a new subprocess, you can not rely anymore on environment variables.
Especially when dealing with large input data, the output from the subprocess does not get piped further and therefore is collected in memory until the program finished, which might lead into a memory problem.
To put it short: if using python solves your problem faster than combining bash-only tools, sure, do it. If that involves launching serious subprocesses, ok. However, if you want to replace bash with python, do not do that.