I want to capture the output of a mysqlsh
script (LOAD DATA):
logs=$(mysqlsh --user=$USER --password=$PASS --socket=/var/run/mysqld/mysqld.sock < /script.js)
echo $logs
script.js:
util.importTable('/my.csv', {schema: 'db', table: 'mytable', dialect: 'csv-unix',
fieldsTerminatedBy: ';', linesTerminatedBy: '\n', replaceDuplicates: true
showProgress: false, bytesPerChunk: '200M', threads: 3, columns: [...]});
On the console I see:
WARNING: Using a password on the command line interface can be insecure.
Importing from file '/my.csv' to table `db`.`mytable` in MySQL Server at /var%2Frun%2Fmysqld%2Fmysqld.sock using 3 threads
[Worker000] db.mytable: Records: 351229 Deleted: 0 Skipped: 0 Warnings: 0
[Worker001] db.mytable: Records: 357374 Deleted: 0 Skipped: 0 Warnings: 0
[Worker002] db.mytable: Records: 352552 Deleted: 0 Skipped: 0 Warnings: 0
...
File '/my.csv' (21.11 GB) was imported in 5 min 22.7004 sec at 65.42 MB/s
Total rows affected in db.mytable: Records: 37129973 Deleted: 0 Skipped: 0 Warnings: 0
BUT: echo $logs
shows an empty line.
Why is the mysqlsh
output not captured here?