Curl installation and basic usage
Installation of the curl is not so complicated. For Debian it is as follows:
apt-get install curl
You may also install php library:
apt-get install php5-curl
There are lot of options you may use in order to calling curl command from terminal. Two of them are useful when you’re trying to run heavy script : --connect-timeout
and --max-time
. Second one is useful for preventing your batch jobs from hanging for hours due to slow connection. Here are quoting from manpage:
--connect-timeout Maximum time in seconds that you allow the connection to the server to take. This only limits the connection phase, once curl has connected this option is of no more use. Since 7.32.0, this option accepts decimal values, but the actual timeout will decrease in accuracy as the specified timeout increases in deci‐ mal precision. See also the -m, --max-time option. If this option is used several times, the last one will be used.
-m, --max-time [seconds] Maximum time in seconds that you allow the whole operation to take. This is useful for preventing your batch jobs from hang‐ ing for hours due to slow networks or links going down. Since 7.32.0, this option accepts decimal values, but the actual time‐ out will decrease in accuracy as the specified timeout increases in decimal precision. See also the --connect-timeout option. If this option is used several times, the last one will be used.
Another important thing is a presence of special chars in url: ?
, &
etc. In this case you have to quote the url. For example:
curl 'https://www.somesite.com/somepath/somescript?get1=foo&get2=bar'
Recent Comments