Transferring Data Using cURL



cURL is free and open source tool used to transfer data. I will show you as an example how to use it to transfer data with the cloud.  Here i will send the commands from Linux console to Openstack. The following are the steps:

Taking An Authentication Token

You need to send an authentication request to the cloud identity web service and get a token in the response upon successful authentication:

# curl -s https://YOUR-Cloud-Identity-Service-URL -X ‘POST’ -d ‘{“auth”:{“passwordCredentials”:{“username”:”YOUR-UserName”, “password”:”YOUR-Password”}}}’  -H “Content-Type: application/json” | python -m json.tool

Upon successful authentication, you will get the response in JSON format. To make the output easy to read, you can direct the output to the “json.tool” python tool as above.

One of the important information in the response is the authentication token which will be passed in the header “X-Auth-Token” in each request you send. You need to extract the token from the JSON respone. You can use the “jsawk” tool.

“jsawk” Installation

Follow these steps to install “jsawk”:

# yum install js, js-devel

# curl -L > jsawk

# chmod 755 jsawk && mv jsawk /usr/bin/

Note curl is used here also.

 How To Use “jsawk”

You direct the response to “jsawk” and ask for a specific property in the JSON response. You can also do some modifications. See the examples in “jsawk” github page.

 More Information


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s