I am building up mysql commands in a perl script and I want to use the -tee option to get a file showing what happened.
So, here below, I am doing the same command. In the first, it is inside a perl script. In the second, it is on the command-line. In both cases, the tee file is created, but when I call it via perl, it is empty. What the heck? :--)
%
% cat test1.pl
#!/usr/bin/perl
open M, "| mysql --tee=x1.txt ca_sos_20200615";
print M "select count(8) from filer_filings;\n";
close M;
% ./test1.pl
Logging to file 'x1.txt'
count(8)
2273504
%
% mysql --tee=x2.txt ca_sos_20200615
Logging to file 'x2.txt'
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 353
Server version: 8.0.19 MySQL Community Server - GPL
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select count(8) from filer_filings;
+----------+
| count(8) |
+----------+
| 2273504 |
+----------+
1 row in set (0.18 sec)
mysql> quit
Bye
%
% ls -l x1.txt x2.txt
-rw-r--r-- 1 ray staff 0 Jul 4 14:24 x1.txt
-rw-r--r-- 1 ray staff 714 Jul 4 14:24 x2.txt
%