I am trying to execute foo.sql using the source command in MySQL.
When I type the command, the file is sourced accordingly:
mysql> source ~/foo.sql >
From within your MySQL client, type
tee session.out
From that point on, all the I/O of in your current client session is written to the file 'session.out'