Bash Scripting; giving commands to programs stdin
===

I am very new to bash scripting. I have the following script:

    cp /etc/apt/sources.list /var/chroot/etc/apt/sources.list
    chroot /var/chroot/
    apt-get update
    apt-get --simulate install $a > output

I actually want the last 2 comands to be run in chroot environment but I do not know how to give it to it, I searched but I could not find. I also want chroot to exit after execution of the commands, but it currently hangs. What can I do to prevent this?
