Hi, upgraded one of the server to RHEL7. A Shell script uses dos2unix to convert EOL characters to Linux format and checks return code. In RHEL6, if conversion fails shell script returns code 1 where as if conversion fails in RHEL7 script returns return code 13. Is it possible to change RHEL7 return code(13) as in RHEL6 (1) ?
[satya@rhel6 tmp]$ cat /etc/redhat-release
Red Hat Linux release 6.x
[satya@rhel6 tmp]$ dos2unix testfile
dos2unix: converting file testfile to UNIX format ...
dos2unix: problems converting file testfile
[satya@rhel6 tmp]$ echo $?
1
[satya@rhel6 tmp]$
[satya@rhel7 tmp]$ cat /etc/redhat-release
Red Hat Linux release 7.x
[satya@rhel7 tmp]$ dos2unix testfile
dos2unix: testfile: Permission denied
dos2unix: converting file testfile to Unix format ...
dos2unix: problems converting file testfile
[satya@rhel7 tmp]$ echo $?
13
[satya@rhel7 tmp]$
Thank you for the reply. Java application executes dos2unix on linux box and look for return codes 0(success) or 1(fail). As failure return code changed in RHEL7, java app code failing. so want to get some idea on whether this 13 return code coming from linux or dos2unix utlity.
--- Post updated at 08:34 PM ---
Thank you RudiC, here is the o/p from RHEL7 and RHEL6. Java application executes dos2unix on linux box and look for return codes 0(success) or 1(fail). As failure return code changed in RHEL7, java app code failing. so want to get some idea on whether this 13 return code coming from linux or dos2unix utlity.
The java code is wrong. The standards say that exit code 0 is success and that failure is denoted by a non-zero value (not just 1). Some utilities have other non-zero exit values that still indicate success, but no program should assume that only exit code 1 means failure.
The standards also specify that the some utilities are required to return exit code 126 if an attempt was made to invoke a utility, a utility by that name was found, but the utility was not in the proper form to execute as a utility and to return exit code 127 if an attempt was made to invoke a utility but no utility of the desired name was found.
First, make sure the two versions react differently to the identical error situation, which is not obvious in post #1. Are both running into the "permission denied" error? If that's the case, and you can't make the java code behave, consider installing the older dos2unix version on the RHEL7 system.