The error "/bin/sh^M: bad interpreter: No such file or directory" occurs when you simply do copy/paste from your windows machine to linux shell prompt. It appends ^M character at end of line. So the shell script execution gives error as mentioned below.
[root@localhost ~]# /usr/local/nagios/libexec/check_dirsize_perf.sh -d /tmp/ -w 100 -c 200
-bash: /usr/local/nagios/libexec/check_dirsize_perf.sh: /bin/sh^M: bad interpreter: No such file or directory
Solution:
You can use dos2unix command to make file usable(remove ^M). Use below command.
[root@localhost ~]# dos2unix -n /usr/local/nagios/libexec/check_dirsize_perf.sh /usr/local/nagios/libexec/check_dirsize_perf_1.sh
dos2unix: converting file /usr/local/nagios/libexec/check_dirsize_perf.sh to file /usr/local/nagios/libexec/check_dirsize_perf_1.sh in UNIX format ...
[root@localhost ~]# mv /usr/local/nagios/libexec/check_dirsize_perf_1.sh /usr/local/nagios/libexec/check_dirsize_perf.sh
mv: overwrite `/usr/local/nagios/libexec/check_dirsize_perf.sh'? y
[root@localhost ~]# /usr/local/nagios/libexec/check_dirsize_perf.sh -d /tmp -w 100 -c 200 -u mb
293 mb - critical
Hope this will help.
No comments:
Post a Comment