![]() ![]() p.pid will be the id of your cmd process then. It is how to spawn a subprocess which continues to run foregrounded after its parent/spawner terminates. I found a convenient fix this by: p subprocess.Popen ('exec ' + cmd, stdoutsubprocess.PIPE, shellTrue) This will cause cmd to inherit the shell process, instead of having the shell launch a child process, which does not get killed. In this case, the point of this question is not to script the submission of ssh credentials to ssh from within Python. Is there a way, only using python, to start/fork an interactive service (like ssh), by using subprocess or some comparable module, and have this forked child process remain alive in the foreground, even after its parent (python) has sys.exit()'d? The problem is, this solution requires the use of either 2 scripts (a bash script to run ssh, combined with the python script to return the arguments) or alternatively human intervention to type the bash command directly as formatted above. The result is, the python program terminates and the user interacts with ssh initialization. In this bash example, after the python script runs, it is replaced or rather substituted with its return value which is, in turn, provided as a input to the program ssh. I'm interested in learning how to achieve the python equivalent of the following bash command: ssh $(./resolve_ip.py) Assume there exists a python script resolve_ip.py which magically returns the string IP of a machine we care about. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |