Error that should return a non 0 status?

When the following error is given:

An unexpected error occurred:
There were too many requests of a given type :: Error creating new cert :: Too many certificates already     issued for exact set of domains: example.com
Please see the logfiles in /data/keys/letsencrypt/log for more details.

it gives an exit status of “0”. For example:

# ssltest:/data # SCRIPT_STATUS=$?
# ssltest:/data # /usr/local/bin/letsencrypt certonly --keep-until-expiring --config /data/config/letsencrypt.cfg
An unexpected error occurred:
There were too many requests of a given type :: Error creating new cert :: Too many certificates already issued for exact set of domains: example.com
Please see the logfiles in /data/keys/letsencrypt/log for more details.
# ssltest:/data # echo $SCRIPT_STATUS
0

Shouldn’t this return an exit code > 0? It would make it easier for scripting and catching this error.

Or am I missing something?

I’m running letsencrypt 0.5.0 on FreeBSD 10.3-RELEASE

Any help would be appreciated.

Hello @SBBH,

My FreeBSD knowdledge is 0 but why are you assigning the return code $? to a variable before execute the command?.

If you assign $? to SCRIPT_STATUS before execute the command, the SCRIPT_STATUS variable will have the value of last executed command before defining that variable.

Example:

I execute ls -l test (test file exists) so the return code is 0.

[root@ctm8 test]# ls -l test
-rw-r----- 1 root root 0 Apr 21 06:52 test
[root@ctm8 test]# echo $?
0

I execute ls -l lalala (lalala file doesn’t exist) so the return code is 2.

[root@ctm8 test]# ls -l lalala
ls: cannot access lalala: No such file or directory
[root@ctm8 test]# echo $?
2

Now I execute ls-l test, assign the return code to SCRIPT_STATUS, execute ls -l lalala and check again the variable SCRIPT_STATUS.

[root@ctm8 test]# ls -l test
-rw-r----- 1 root root 0 Apr 21 06:52 test

[root@ctm8 test]# SCRIPT_STATUS=$?

[root@ctm8 test]# ls -l lalala
ls: cannot access lalala: No such file or directory

[root@ctm8 test]# echo $SCRIPT_STATUS
0

As yo can see the value of SCRIPT_STATUS is 0 but it should be 2.

I hope this helps you to understand the reason you are receiving a 0 return code.

Cheers,
sahsanu

2 Likes

You are so right, I’m not sure how I missed that. Thank you very much!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.