Solved 2>/dev/null does not work.

bagas

Well-Known Member

Reaction score: 9
Messages: 292

Hello.
There is a console script that monitors ssl certificates of sites on the server.
echo | openssl s_client -servername mydomain.com -connect mydomain.com:443 2>/dev/null | openssl x509 -subject -noout -dates -issuer
We end up with.
Code:
subject=CN = mydomain.com
notBefore=Jul 29 00:00:00 2020 GMT
notAfter=Oct 17 23:59:59 2022 GMT
issuer=C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA
This command works on Linux, in FreeBSD the link 2>/dev/null does not work.
What should be done in this case?
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,696
Messages: 39,295

2> /dev/null is a Bourne shell type redirection. Root on FreeBSD has a C shell, that uses a different syntax for redirections. Either use sh(1) to execute those commands or read the csh(1) manual on how to redirect the "C shell" way.

I'll give you a hint though, C shell doesn't allow you to redirect STDERR seperately.
Code:
       The shell cannot presently redirect diagnostic output without also
       redirecting standard output, but `(command > output-file) >& error-
       file' is often an acceptable workaround.  Either output-file or error-
       file may be `/dev/tty' to send output to the terminal.
 
OP
bagas

bagas

Well-Known Member

Reaction score: 9
Messages: 292

Pointed out the bash shell in the script.
#!/usr/local/bin/bash
It remains only to correct the commands in the script for the domains.
In general, I think the problem has been solved.
Thanks for assistance.
 
Top