Home > AIX, Commands, commands, Linux, Web Design > Linux – Curl command

Linux – Curl command

The curl command is used to retrieve/send documents/files from/to the server using any of the following protocols: (HTTP, HTTPS, FTP, GOPHER, DICT, TELNET, LDAP or FILE). It is designed to work without any form of interactivity. It can perform a shed load of functions including but not limited to user authentication, cookies, FTP upload etc

In my case I wanted to action a script via HTTP with user authentication. This can be done in curl by issuing the following:

$ curl --user username:password http://example.com/script

It’s also possible to user curl in the same way you would post a form in html by using the –data flag:

$  curl --data "variable1=<variable" http://example.com/actionscript

So for example you have the following form…

<form method="POST" action="submit.cgi">
 <input type=text name="username">
 <input type=text name="birthyear">
 <input type=submit name=press value="OK">
</form>

and are passing username, year of birth, etc… it would be something like:

$ curl --data "username=kerrirobberts&birthyear=1986&submit=ok" http://example.com/submit.cgi

Further Reading

There are many more commands that curl can perform, these can be found in the following more detailed articles:

http://linux.about.com/od/commands/l/blcmdl1_curl.htm
http://curl.haxx.se/docs/httpscripting.html

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

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

WordPress.com Logo

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

%d bloggers like this: