switched from spawning the cmds to execing them; added stdin redirection