On Thu, Nov 14, 2013 at 1:31 AM, Himanshu Garg <hgarg.in...@gmail.com> wrote: > I am writing a python script to run chroot command to chroot to a linux > distro and then run commands. How can I do this, as after chrooting, the > script runs the commands relative to the outside not inside the chrooted env?
Probably the easiest way to do this is to divide your script into two pieces: one piece runs inside the chroot, the other doesn't. Then you have the "outer" script invoke the "inner" script as a separate process. When the inner process terminates, the outer continues, and since the outer wasn't chrooted, it's now running commands relative to the outside. One convenient way to manage this is to have one script that invokes itself with arguments. Another way is to have two actually separate script files. It really depends how much work you're doing in each half. ChrisA -- https://mail.python.org/mailman/listinfo/python-list