Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to cURL a JAR from remote URL

Tags:

java

curl

I have a JAR that is available for download from an HTTP URL, say, http://somerepo.example.org/myjar-1.0.jar.

I need a cURL command that will download it to the current directory; my best attempt thus far is:

curl -i -H "Accept: application/zip" -H "Content-Type: application/zip" -X GET http://somerepo.example.org/myjar-1.0.jar

When I run this my console fills with binary spam and seems to cause my entire terminal to have a melt down.

What is the correct cURL command to GET a JAR from a remote URL?

like image 556
smeeb Avatar asked May 12 '15 15:05

smeeb


People also ask

How do you curl a URL?

The syntax for the curl command is as follows: curl [options] [URL...] In its simplest form, when invoked without any option, curl displays the specified resource to the standard output. The command will print the source code of the example.com homepage in your terminal window.

How do I run a JAR file on a remote server?

Create a batch file to execute java -jar hellofile. jar from remote cmd. Now run the batch file from your local machine by PSEXEC \othermachine z:\program.exe. You will need administrator privileges on the target machine.

How do I download a file from URL using curl?

Grab file with curl run: $ curl https://your-domain/file.pdf. Get file using ftp or sftp protocol: $ curl ftp://ftp-your-domain-name/file.tar.gz. You can set the output file name while downloading file with the curl, execute: $ curl -o file. pdf https://your-domain-name/long-file-name.pdf.


1 Answers

You are almost there. By default cURL will output the download to STDOUT. You want to redirect this to a file like so:

curl -H "Accept: application/zip" http://somerepo.example.org/myjar-1.0.jar > myfile.jar

You can also use the -o option:

curl -H "Accept: application/zip" http://somerepo.example.org/myjar-1.0.jar -o myfile.jar

You should also be able to use wget

wget http://somerepo.example.org/myjar-1.0.jar
like image 139
14 revs, 12 users 16% Avatar answered Nov 12 '22 05:11

14 revs, 12 users 16%