Following is the script to copy all libraries of a certain command to make my chroot environment.
./cplb.sh /bin/ls will copy all the libraries of
ls command (i.e., the files listed by
ldd /bin/ls command).
CHROOT='/var/chroot' mkdir $CHROOT for i in $( ldd $* |cut -d " " -f3 |sort |uniq) do cp --parents $i $CHROOT done echo "Chroot jail is ready. To access it execute: chroot $CHROOT"
Now, when I run
./cplb.sh /bin/ls it works like a charm. But when I run it for multiple commands at the same time, for example:
it throws an error saying:
cannot stat : '/bin/ls:' file or dir not found cannot stat : '/bin/cat:' file or dir not found
I can see a colon after the command, i.e.,
/bin/ls: and that colon causes the error. Now, where does it come from and how to resolve this, so that I can run the script for multiple commands at the same time?