I've read how to log certain scripts or commands individually, but nothing on how to log all commands from within a BASH shell. What I want to do is:
You can't do this in a script that runs under its own shell (i.e. it starts with
#!/bin/bash and you
chmod +x and invoke it like an executable). The redirect affects the subshell but it can't reach the parent to do what you want. You can
. the file (as in
. ./myscript.sh) which will execute the commands in your shell and then you can redirect things as you want.
The other way to do it would be for your script to start a subshell itself (which would inherit stdin, stdout, stderr). This is what the
script command does. It logs everything to a file named (by default)
typescript until the user exits the subshell.