I am trying to output all stdout and stderr both to console and to a file. I know about ./script | tee somefile , but that doesn't work for me. I want it to do it automatically, without me piping it from the console. I've tried
#!/bin/sh
exec 2>&1 | tee somefile
echo "..."
but that didn't work. What would be the correct solution?