System.cmd collects the standard output from the command and returns it, but here it happens that OpenSSL writes a standard error, which by default is not fixed and, therefore, is simply printed on the terminal.
You can use the stderr_to_stdout option:
iex(2)> {_, 0} = System.cmd "openssl", [ "genrsa", "-out", "key.pem", "2048"], [stderr_to_stdout: true] {"Generating RSA private key, 2048 bit long modulus\n.......................+++\n......................................+++\ne is 65537 (0x10001)\n", 0}
This means that the output will be returned in the first element of the tuple instead of typing on the terminal. Since you ignore this part of the return value, it will not be displayed when your program starts.
source share