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

You tin terminate purpose either curl or wget ascendency to transportation HTTP asking from UNIX or Linux operating system. Both commands allow you lot to transportation GET too POST request, which agency you lot tin terminate likewise telephone telephone REST spider web services.  I accept a Java spider web application, which runs on Linux too 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 ascendency should I use? If you lot are likewise facing the same question, too therefore you lot accept come upwardly to correct place. Basically, you lot tin terminate purpose 2 UNIX commands to brand the HTTP request, wget, too curl. You tin terminate purpose ringlet too wget to transportation both GET too POST HTTP request. My purpose illustration was rather simple, I simply remove to brand a GET telephone telephone to spider web service to download the data, but these 2 commands are really powerful too render many dissimilar options to interact amongst the spider web using HTTP correct from the shell.

Between wget too curl (also known every bit cURL), ringlet (I telephone telephone it "karl") is my favorite. Why? I think because I accept used it to a greater extent than ofttimes than wget :-). You tin terminate brand your choices if you lot accept skillful cognition of Linux ascendency trouble too 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 endure out efficient inward Linux. Now let's run across how to transportation HTTP asking from UNIX using  the ringlet command.

 ascendency to transportation HTTP asking from UNIX or Linux operating organisation How to transportation HTTP asking from UNIX or Linux? Use ringlet or wget command



UNIX ascendency to transportation HTTP GET request

Here is i illustration of calling spider web service from Linux crunch yesteryear sending HTTP GET request using cURL command:

$ ringlet 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 terminate likewise specify timeout using -m alternative every bit shown below:

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

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


You tin terminate likewise purpose wget to transportation HTTP asking too download the data. Only departure betwixt curl too wget is that curl volition impress output inward console too wget volition shop it inward the file e.g.

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

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

Here is how you lot tin terminate purpose ringlet to download wget ascendency inward UNIX:

 ascendency to transportation HTTP asking from UNIX or Linux operating organisation How to transportation HTTP asking from UNIX or Linux? Use ringlet or wget command


UNIX ascendency to transportation HTTP POST request

You tin terminate likewise purpose ringlet to transportation HTTP post service request. All you lot remove to create is purpose 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 transportation a information from file to spider web service, you lot tin terminate likewise purpose the next command:

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

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

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


That's all nigh how to transportation HTTP asking from UNIX too Linux. It's simple, simply think ringlet too wget command. you lot tin terminate explore their alternative yesteryear using human wget too human curl. Also, think the departure betwixt ringlet too wget, erstwhile prints the output inward the console acre afterward shop the response inward the same file every bit requested. I personally similar ringlet because it's easier to purpose but if you lot similar wget stick amongst it.

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

  • Thanks for reading this article therefore far. If you lot similar this article too therefore delight percentage amongst your friends too colleagues. If you lot accept whatsoever questions or feedback too therefore delight driblet a note.

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

    Post a Comment

    Iklan Atas Artikel

    Iklan Tengah Artikel 1

    Iklan Tengah Artikel 2

    Iklan Bawah Artikel