Download Oracle JDK using Wget

Downloading Oracle Jdk becomes pain when you want to download it in shell prompt using wget command.
Since oracle does not allow to download oracle jdk without accepting agreement, only wget command will not help you without some other extra switches.

Finally I have found how we can download Oracle JDK in remote server in shell using wget command. Below command can be used to download.

/bin/sh^M: bad interpreter: No such file or directory



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.