How To Post Http Asking From Unix Or Linux? Purpose Whorl Or Wget Command

You tin role either curl or wget ascendence to ship HTTP asking from UNIX or Linux operating system. Both commands allow you lot to ship GET as well as POST request, which agency you lot tin likewise telephone telephone REST spider web services.  I convey a Java spider web application, which runs on Linux as well as exposes WebServices. I was writing a UNIX script to download In about information from that spider web service when I hitting yesteryear the question, how create I brand an HTTP telephone telephone from UNIX? What is the UNIX ascendence should I use? If you lot are likewise facing the same question, thence you lot convey come upwards to correct place. Basically, you lot tin role 2 UNIX commands to brand the HTTP request, wget, as well as curl. You tin role curlicue as well as wget to ship both GET as well as POST HTTP request. My role instance was rather simple, I only involve to brand a GET telephone telephone to spider web service to download the data, but these 2 commands are real powerful as well as render many dissimilar options to interact amongst the spider web using HTTP correct from the shell.

Between wget as well as curl (also known equally cURL), curlicue (I telephone telephone it "karl") is my favorite. Why? I think because I convey used it to a greater extent than oft than wget :-). You tin brand your choices if you lot convey practiced cognition of Linux ascendence delineate of piece of occupation as well as that's why I propose every Java developer to read The Linux Command Line: Influenza A virus subtype H5N1 Complete Reference, the best way to larn efficient inwards Linux. Now let's run across how to ship HTTP asking from UNIX using  the curlicue command.

 ascendence to ship HTTP asking from UNIX or Linux operating organisation How to ship HTTP asking from UNIX or Linux? Use curlicue or wget command



UNIX ascendence to ship HTTP GET request

Here is i representative of calling spider web service from Linux musical rhythm out yesteryear sending HTTP GET request using cURL command:

$ curlicue http://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=bd82977b86bf27fb59a04b61b657fb6f {"coord":{"lon":-0.13,"lat":51.51},"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04n"}],"base":"stations","main":{"temp":282,"pressure":1022,"humidity":87,"temp_min":277.15,"temp_max":285.15},"visibility":10000,"wind":{"speed":1.5},"clouds":{"all":90},"dt":1445577409,"sys":{"type":1,"id":5093,"message":0.0201,"country":"GB","sunrise":1445582275,"sunset":1445619056},"id":2643743,"name":"London","cod":200} 

You tin likewise specify timeout using -m alternative equally shown below:

$ curlicue -m 2 http://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=bd82977b86bf27fb59a04b61b657fb6f

This asking volition timeout inwards 2 seconds if it doesn't have whatsoever response.


You tin likewise role wget to ship HTTP asking as well as download the data. Only divergence betwixt curl as well as wget is that curl volition impress output inwards console as well as wget volition shop it inwards the file e.g.

$ wget http://localhost:8080/index.html

volition download the content of index.html as well as shop into a file amongst the same name.

Here is how you lot tin role curlicue to download wget ascendence inwards UNIX:

 ascendence to ship HTTP asking from UNIX or Linux operating organisation How to ship HTTP asking from UNIX or Linux? Use curlicue or wget command


UNIX ascendence to ship HTTP POST request

You tin likewise role curlicue to ship HTTP postal service request. All you lot involve to create is role the --data alternative to specify the information you lot desire to POST to spider web service e.g.

$ curl --data "param1=value1&param2=value2" http://locahost:8080/weather

if you lot desire to ship a information from file to spider web service, you lot tin likewise role the next command:

$ curlicue -X POST -d @filename http://locahost:8080/weather

Similarly, if you lot desire to upload a file you lot tin create thence yesteryear executing the next command:

$ curlicue --form "fileupload=@filename.txt" http://locahost:8080/weather


That's all most how to ship HTTP asking from UNIX as well as Linux. It's simple, only recollect curlicue as well as wget command. you lot tin explore their alternative yesteryear using human wget as well as human curl. Also, recollect the divergence betwixt curlicue as well as wget, old prints the output inwards the console field after shop the response inwards the same file equally requested. I personally similar curlicue because it's easier to role but if you lot similar wget stick amongst it.

Further Learning
Linux Command Line Basics
examples)
  • 10 examples of grep ascendence inwards UNIX (examples)
  • 10 examples of engagement ascendence inwards Linux (examples)
  • How to larn IP address from hostname as well as vice-versa inwards Linux (command)
  • 10 examples of xargs ascendence inwards Linux (examples)
  • 10 examples of tar ascendence inwards UNIX (examples)
  • 10 examples of Vim inwards UNIX (examples)
  • How to create, update as well as delete soft link inwards UNIX (command)
  • How to delete empty files as well as directory inwards UNIX (solution)
  • How to brand directory tree inwards i command? (example)
  • How to how long declaration of a procedure inwards Solaris (command)
  • UNIX ascendence to uncovering out how long a procedure is running? (answer)
  • UNIX ascendence to uncovering the size of file as well as directory? (command)
  • 5 examples of kind ascendence inwards Linux (examples)
  • 5 examples of kill ascendence inwards Linux (examples)
  • 10 examples of chmod ascendence inwards UNIX (examples)
  • 10 tips to operate fast inwards UNIX? (tips)

  • Thanks for reading this article thence far. If you lot similar this article thence delight percentage amongst your friends as well as colleagues. If you lot convey whatsoever questions or feedback thence delight driblet a note.

    Sumber https://javarevisited.blogspot.com/

    0 Response to "How To Post Http Asking From Unix Or Linux? Purpose Whorl Or Wget Command"

    Post a Comment

    Iklan Atas Artikel

    Iklan Tengah Artikel 1

    Iklan Tengah Artikel 2

    Iklan Bawah Artikel