Hello,
I have a MySQL 5.1.56 server running on Linux.
I want to be use the command line tool to run some queries in a .sql file and then output the results to a text file.
When I run my command from Terminal it works as expected, but when I run the same thing from a batch file it doesn't. The output text file is created, but nothing is written to it.
My batch file is as follows:
#!/bin/bash
mysql -uUSER -pPASSWORD db_name < /path/to/file.sql > /path/to/output.txt
For testing purposes my .sql file only contains a simple SELECT statement.
Like I said, when I run this:
mysql -uUSER -pPASSWORD db_name < /path/to/file.sql > /path/to/output.txt
from Terminal it works fine and output.txt contains the output of the SELECT statement. The batch file will create output.txt but there isn't anything in it... What am I doing wrong??
Thanks for the help!