Question

I would like to do something like this:

chroot /mount-point /path/to/script $var1 $var 2

Will this work? Will the chrooted Perl script be passed on these 2 parameters? If not, how to do this?

Otherwise, is there any way to simply do chroot in the script, and then start doing commands such as

perl script.pl $var1 $var2 etc?

As I understand it, simply writing them sequentially in bash will only get them executed after chroot is finished, and control is returned back to where I don't have perl installed (its a ramdisk running from PXE).

Was it helpful?

Solution

Chroot should handle this just fine. Just make sure that your perl script can find a Perl interpreter from the chroot context, that the Perl executable can find the shared libraries it needs, and that your variables, if they contain paths, have paths relative to the new root, not the old. You may want to compile a statically-linked perl executable, if that's easier for you than making copies of the required shared libraries in the chroot.

OTHER TIPS

Or you can use Expect, which is a scripting language for interacting with input/output. http://en.wikipedia.org/wiki/Expect

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top