[英]java - execute commands in chroot
I have a python script that runs some scripts and commands against a chroot that and I would like to migrate it to Java. 我有一个python脚本,可以对chroot运行一些脚本和命令,我想将其迁移到Java。
In python, to work on the chroot, I am doing the following: 在python中,要在chroot上工作,我正在执行以下操作:
os.chdir(root)
os.chroot(root)
And, then when I'm done, I'm doing: 然后,当我完成后,我在做:
os.fchdir(real_root)
os.chroot('.')
os.close(real_root)
Whenever I execute any commands in python, they're executed against the chroot and I'd like to do the same in Java. 每当我在python中执行任何命令时,它们都会针对chroot执行,而我想在Java中执行相同的操作。
Is this possible, what facilities would I need to use to make this work? 这有可能吗,我需要使用什么设施来完成这项工作?
The way I am doing it isn't fancy, but it works. 我这样做的方法并不花哨,但可以。 Is there a better solution?
有更好的解决方案吗?
1. mount all filesystems
2. run chroot some-shell
3. use expect library (or something equivalent)
4. unmount filesystems
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.