I'm generating an RSA keypair using the openssl command line on Elixir, and everything works except I haven't been able to suppress the output of that command.
This is what I'm running:
{_, 0} = System.cmd "openssl", [ "genrsa", "-out", "privateKey.pem", "2048"]
and I keep getting:
Generating RSA private key, 2048 bit long modulus .....+++
.....................................+++ e is 65537 (0x10001)
After I compile with escript and run the executable.
System.cmd
collects standard output from the command and returns it, but what's happening here is that OpenSSL is writing to standard error, which by default isn't captured, and thus just gets printed to the terminal.
You can use the option stderr_to_stdout
:
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}
That means that the output will be returned in the first tuple element instead of printed to the terminal. Since you ignore that part of the return value, it won't be output when you run your program.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With