Reputation: 45
I'm trying to run this command line in Azure Batch node start up task
sudo wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux-x64.rpm" && sudo yum localinstall jdk-8u161-linux-x64.rpm -y
However, It always failed with this kind of error in the log file
Usage: wget [OPTION]... [URL]...
Try `wget --help' for more options.
Looks like it doesnt understand the && operator. I've remotely logged in the VM via ssh and try the command and it worked. Please advice if you've got any experience with this. Any help is appreciated! Thank you
Upvotes: 2
Views: 2664
Reputation: 1266
You should start the command with /bin/bash -c
and then put the command in double quotes, escaping the inner double quotes.
So something like this should work:
/bin/bash -c "sudo wget --no-cookies --no-check-certificate --header \"Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie\" \"http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux-x64.rpm\" && sudo yum localinstall jdk-8u161-linux-x64.rpm -y"
Upvotes: 11