10 Examples Of Wrap Dominance Inward Unix Together With Linux

The curl is ane of the essential commands to ship HTTP requests from UNIX in addition to Linux operating System. ringlet dominance is role of the cURL bundle in addition to it's non only useful to ship HTTP request but also allows yous to transfer file using FTP in addition to ship postal service using SMTP. The cURL utility supports many protocols including DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAP, LDAPS, LDAP, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMTP, SMTP, Telnet, in addition to TFTP. It also supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP cast based upload, proxies, HTTP/2, cookies, user+password authentication (Basic, Plain, Digest, CRAM-MD5, NTLM, Negotiate in addition to Kerberos), file transfer resume, proxy tunneling in addition to more. It's specially useful if yous are working amongst web services.

You tin utilisation the curl dominance to telephone telephone spider web services correct from UNIX dominance prompt, have a response, banking corporation jibe whether your server is good for yous or not. You tin write testing in addition to monitoring scripts using curl command. It's similar to wget command, which is also used for HTTP requests but it's much to a greater extent than powerful in addition to supports many protocols.

The ringlet dominance is past times default available inwards many UNIX installation but if it's non yous tin ever download the latest version from http://curl.haxx.se/download.html, the latest version of the cURL bundle is ringlet 7.43.0, released on 17th June 2015. cURL has unlike packages available for unlike UNIX flavour e.g. Linux, Debian, Fedora, ArchLinux, AIX, FreeBSD, Suse, Redhat, Ubuntu in addition to fifty-fifty for Mac OS X in addition to Apple iOS.



10 Example of ringlet dominance inwards Linux

Here are around of the useful examples of ringlet dominance inwards Linux. You tin utilisation this dominance to examine your REST API from the Linux dominance line. You tin also banking corporation jibe if your spider web application is upward in addition to downward past times using ringlet dominance inwards a script in addition to and thus running it from crontab or a scheduling application similar Autosys.

1) How to ship HTTP asking from UNIX
You tin utilisation curl or wget to ship HTTP asking from UNIX, every bit shown below:

$ ringlet http://google.com

By default, ringlet uses GET method to ship HTTP request. You tin also utilisation inquiry parameters acre connecting to spider web services using HTTP every bit shown below:

$ ringlet http://api.openweathermap.org/data/2.5/weather?id=2172797


Don't forget to include URL within unmarried quotes if yous include to a greater extent than than ane inquiry parameters. Why? because multiple inquiry parameters are separated using & which has special pregnant inwards the shell, to run the dominance inwards the background, past times including it within unmarried quotes nosotros utilisation it literally, every bit shown below:

$ ringlet 'http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139'



2) How to render timeout for HTTP asking inwards UNIX
Another interesting instance of ringlet dominance is past times using -m option. You tin utilisation curl -m pick to render a timeout for HTTP request. If server volition non render whatever reply within specified fourth dimension menstruum in addition to thus ringlet volition exit, every bit shown below

$ ringlet -m 3 'http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139'

volition hold off for 3 seconds before timing out. BTW, -m is used for a brace of things inwards ringlet e.g. for the maximum seat out of redirects in addition to maximum file size to download.

Alternatively, yous tin utilisation to a greater extent than verbose --max-time, --max-redirs in addition to --max-filesize options. Worth noting is maximum fourth dimension allowed for transfer is inwards seconds, which agency -m 5 agency five seconds. You tin utilisation this pick to banking corporation jibe whether your website or spider web service is responsive or not.

 is ane of the essential commands to ship HTTP requests from UNIX in addition to Linux operating Syst 10 Examples of ringlet Command inwards UNIX in addition to Linux


3) How to ship HTTP POST asking from Linux
You tin ship whatever type of HTTP asking past times using ringlet -X dominance inwards Linux. It allows yous to specify HTTP methods other than GET, for example, next dominance volition ship HTTP POST asking from linux dominance line:

$ ringlet -X POST http://api.openweathermap.org

Since GET is the default method, yous don't ask to specify it but if yous desire to ship other HTTP methods e.g. PUT or POST, yous tin utilisation this option. Btw, what is the utilisation of POST asking without sending whatever data? Let's run across our adjacent example, which allows yous to ship information to the server using ringlet command.


4) How to ship information using HTTP POST inwards UNIX
You tin also ship POST asking using ringlet -d option. -d is null but for data, which is sent every bit POST body. The information is expected to live on URL-encoded.

$ ringlet -d 'lat=35&lon=139' http://api.openweathermap.org/data/2.5/weather

This volition ship inquiry parameters every bit a POST request. You tin also utilisation -d pick multiple times to specify unlike information pieces e.g.

$ ringlet -d lat=35 -d lon=139 http://api.openweathermap.org/data/2.5/weather

This volition eventually live on combined every bit -d 'lat=35&lon=139'. The -d pick tin also live on used to submit HTML cast information to the server. You tin run across The Linux dominance line:  A consummate Introduction for to a greater extent than details on sending information using ringlet command.

 is ane of the essential commands to ship HTTP requests from UNIX in addition to Linux operating Syst 10 Examples of ringlet Command inwards UNIX in addition to Linux



5) How to ship a file via HTTP POST inwards Linux
If your information is large, yous tin move out on them within a file in addition to say ringlet the file name. It volition transfer all that information using HTTP mail asking to the server, hither is an instance of sending a file using curl:

$ ringlet -d @requestData.txt http://api.openweathermap.org/data/2.5/weather

The @ sign tells ringlet that whatever follows is a file name. BTW, the content of file must live on URL encoded. You tin also use --data instead of -d if yous prefer the most verbose option.


6) How to ship username password for authentication using curl
You tin utilisation ringlet -u pick to move past times username in addition to password for authentication. The -u pick is a shortcut of --user pick which specifies username in addition to password for server authentication. If yous using twitter, hither is how yous tin update your condition using ringlet dominance correct from UNIX:

$ ringlet -u username:password -d status='curl is great'  http://twitter.com/statuses/update.xml


If yous don't wishing your password to live on saved inwards the trounce history, yous tin omit password role in addition to ringlet volition prompt for password when it tries to authenticate on the server. As I told earlier, -d instructs ringlet to utilisation HTTP POST method to ship a asking in addition to "status=.." volition live on sent every bit role of the asking body. You tin farther read Practical guide to Linux dominance in addition to trounce editors to larn to a greater extent than close it.

 is ane of the essential commands to ship HTTP requests from UNIX in addition to Linux operating Syst 10 Examples of ringlet Command inwards UNIX in addition to Linux



7) How to specify HTTP header using ringlet dominance inwards Linux
You tin specify HTTP header past times using curl -H option. Since amongst spider web service yous oft bargain amongst either JSON or XML rather than HTML, it makes feel to specify content-type every bit either "application/json" or "application/xml". You tin exercise this using ringlet every bit shown inwards the next example:

$ ringlet -H "Accept: application/json"  'http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139'

You tin also utilisation headers acre sending information to server using HTTP mail e.g.

$ ringlet -X PUT \ -H 'Content-Type: application/json' \ -d '{"id":"101", "description":"baby soap"}' http://localhost:8080/item/add

One side tip, yous tin separate your UNIX command into multiple lines past times using \ (backslash). It makes your dominance to a greater extent than readable, especially if it's getting long.


8) How to persuasion HTTP reply header inwards Linux
You tin utilisation the curl -i dominance to persuasion reply header inwards UNIX. Since API in addition to WebService provider is increasingly using HTTP header to render information close caching, content-type, potency etc, it's really useful to run across HTTP header using ringlet every bit shown below:

$ ringlet -i http://api.openweathermap.org/data/2.5/weather?zip=94040,us

This volition render all reply headers from HTTP reply every bit shown below:

 is ane of the essential commands to ship HTTP requests from UNIX in addition to Linux operating Syst 10 Examples of ringlet Command inwards UNIX in addition to Linux


That's all close how to utilisation ringlet dominance to ship HTTP asking in addition to have a response. We accept seen several examples of ringlet dominance ranging from sending uncomplicated HTTP asking to timeout, amongst inquiry parameters in addition to unlike types of HTTP asking e.g. POST, PUT, in addition to DELETE.

It's genuinely a must know tool if yous are working amongst REST spider web services which render JSON or XML output. You tin examine your spider web services correct from UNIX box, tin construct scripts to examine in addition to monitor them every bit well. As a Java developer, I utilisation ringlet a lot when I operate amongst spider web services based application.

Further Learning
Linux Command Line Basics
examples)
10 examples of grep dominance inwards Linux (see)
10 examples of sed dominance inwards UNIX (see)
10 examples of chmod dominance inwards Linux (see)
10 examples of xargs dominance inwards Linux (see)
10 Essential Networking commands inwards Linux (see)
10 examples of lsof dominance inwards Linux (see)
10 Examples of tar dominance inwards Linux (see)

Thanks for reading this tutorial, if yous similar in addition to thus delight part amongst friends in addition to colleagues. If yous accept whatever other interesting ringlet examples, which yous utilisation daily or uncovering useful, experience gratis to part amongst us too., 

0 Response to "10 Examples Of Wrap Dominance Inward Unix Together With Linux"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel