Save the output to a file (script.txt) and run it with command:
sql -thin /nolog @script.txt