How To Use Basic UNIX Commands for cURL

CURL, a program that is command-line only, is a program used to request and get data and information from your server. These requests to the server are made from several kinds of protocols like LDAP, HTTP, SFTP, FTP, TELNET, TFTP, and a lot more other protocols. The greatness of the cURL command-line is based on the fact that its operations can be very, very complex. And because of the complexity and elaborateness of the operations in cURL, this is also its downfall. Even the most basic UNIX commands can be used in cURL. Just follow the few basic steps below in using commands from UNIX in cURL.

  • Activate your cURL. The cURL is really easy for you to activate. You just have to type in (in a BASH prompt) “curl [url]” in which your “[url]” will be your Resource Locator Address of your data that you want to request for in the server. If there are no outputs specified retrieved, the cURL will receive the data and save it on the same location as where your command was used.
  • Knowing the defaults of the cURL. By default, there are several efficient ways the cURL uses to retrieve data. In its first step, cURL will try to figure out automatically the proper protocol it will use solely based on the commands you type in. When the URL typed in is a bit ambiguous, HTTP will be the first protocol used. But when the URL used has a familiar hostname, like the URL, then cURL will try to use FTP protocol using the hostname.
  • Understanding the request consolidation. As an additional feature, cURL will also try to consolidate or merge all the requests that are coming in all to one server. Meaning, the program will attempt to combine all the commands to the server into a Single Server Request to avoid using multiple sessions and adding traffic to the overhead of the TCP.
  • A list of some basic UNIX commands to be used in the program
    • -create-dirs
      • This command will produce a mirrored hierarchy tree from the composition of the URL requested. The command must be used also with the option –o, where it states the location where your data will be saved locally. In the –o option, if there are no directory name used of when the name of the directory mentioned is already existing, there will be no directory created.
    • -d
      • The –d command is also like a common “POST” command in HTTP. This option is very useful in copying browser instances in which the user would type in value in a text input form.
    • -f
      • This command is very close to the –d command. The only difference is this type of command will send your POST only upon pressing of the Submit button.
    • -o [file]
      • The –o command writes data to the location specified in the command where the [file] is the path used for saving the data.
    • -u user:password
      • This command will specify the username and the password used in accessing the server.
    • -s
      • This command will activate silent mode where there will be no outputs displayed.
    • -v
      • This command will put your program into the Verbose mode where statistics and status bars are produced simultaneously with the data received.
    • -A
      • This command is used to name a specific Browser Agent String.
    • -h or –help
      • This option will list down commands that can be used in cURL.

Now you are already armed with these basic commands, which you can further branch out and study in the future. Good luck!


Share this article!

Follow us!

Find more helpful articles: