0

I want to append STDOUT or STDERR of command mysql_secure_installation to a file for example /tmp/output.txt but no success on below commands:

mysql_secure_installation >> /tmp/output.txt
mysql_secure_installation 1>> /tmp/output.txt
mysql_secure_installation 2>> /tmp/output.txt

Also tested STDIN and reserved buffers by below commands:

mysql_secure_installation 0>> /tmp/output.txt
mysql_secure_installation 3>> /tmp/output.txt
...
mysql_secure_installation 9>> /tmp/output.txt

It seems mysql_secure_installation output buffers is many different from other commands and it's buffer cannot accessible. Is this true and how to handle it?

UPDATE 1:

CentOS tested and buffer works perfect but on my target os ( Ubuntu 16.04 LTS ) it doesn't work.

UPDATE 2:

Worked on Debian 9 too, but problem on ( Ubuntu 16.04 LTS ) exists.

Behnam
  • 2,212
  • 2
  • 22
  • 32
  • Looking at the [source code](https://github.com/twitter/mysql/blob/master/scripts/mysql_secure_installation.sh), `echo` is used normally to output to stdout. I'm sure you've seen it, but just in case, try checking out [this question](https://stackoverflow.com/questions/24270733/automate-mysql-secure-installation-with-echo-command-via-a-shell-script) – Addison Nov 03 '17 at 03:31
  • @Addison Thanks for your comment and linking source. You are right. `echo` used for generating output, but i don't know why won't work. About automating using batch, I saw it before by not solve my problem or anything to clearify it. – Behnam Nov 03 '17 at 03:40
  • 1
    Well, I might try to replicate this on a LiveCD if I get a chance this weekend. It's an interesting problem – Addison Nov 03 '17 at 03:50

0 Answers0