interm: Added pages on watch and curl
git-svn-id: svn+ssh://atelier.inf.usi.ch/home/bevilj/group-1@183 a672b425-5310-4d7a-af5c-997e18724b81
This commit is contained in:
parent
bcc3e2aa86
commit
1e9b6f2310
2 changed files with 123 additions and 0 deletions
site/pages/cmd/interm
83
site/pages/cmd/interm/curl.html
Normal file
83
site/pages/cmd/interm/curl.html
Normal file
|
@ -0,0 +1,83 @@
|
|||
---
|
||||
layout: page
|
||||
category-page: intermediate
|
||||
category-title: Intermediate commands
|
||||
tags: curl download http client crawler request online
|
||||
author: Claudio Maggioni
|
||||
title: curl
|
||||
---
|
||||
<p>
|
||||
The <code>curl</code> command is a fast and versatile shell program that can
|
||||
request online content using various protocols, including <em>HTTP</em>,
|
||||
<em>FTP</em> and <em>POP3</em>. Some example use cases for this utility are
|
||||
the need to automate some remote call to a server, testing <em>REST</em> or
|
||||
<em>SOAP</em> apis or simply download or display the <em>HTML</em> code of a
|
||||
website.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The name, as mentioned in the <a href="https://ec.haxx.se/curl-name.html">
|
||||
<em>Evertything curl</em></a> online book, stands for <em>"client URL"</em>
|
||||
and the right pronunciation rhymes with "earl" or "girl". By this fact, the
|
||||
reader is able to tell the author of this page to stop pronuncing it as
|
||||
<em>"cooorl"</em>, like if the name is some sort of word in the
|
||||
<a href="https://en.wikipedia.org/wiki/Bergamasque_dialect"><em>Bergamasque
|
||||
dialect</em></a>.
|
||||
</p>
|
||||
|
||||
<h3>Usage</h3>
|
||||
|
||||
<p>
|
||||
<code>curl</code> is a very complex command: if you want to learn it deeply,
|
||||
please refer to the previously mentioned guide called
|
||||
<a href="https://ec.haxx.se/"><em>Evertything curl</em></a>. Some basic
|
||||
ways to use this command are shown below:
|
||||
</p>
|
||||
|
||||
<h4>Download the contents of the page "example.com" to "file.html"</h4>
|
||||
|
||||
<pre>
|
||||
curl example.com -o file.html
|
||||
</pre>
|
||||
|
||||
<h4>Download the contents of the page "en.wikipedia.org/wiki/Curl" to
|
||||
a file with the same name as the last element in the path (here "Curl")</h4>
|
||||
|
||||
<pre>
|
||||
curl -O en.wikipedia.org/wiki/Curl
|
||||
</pre>
|
||||
|
||||
<h4>Download the contents of the page "example.com" to "file.html"</h4>
|
||||
|
||||
<pre>
|
||||
curl example.com -o file.html
|
||||
</pre>
|
||||
|
||||
<h4>Download the contents of the page "example.com" following location
|
||||
redirects (<code>-L</code> flag)</h4>
|
||||
|
||||
<pre>
|
||||
curl -O -L example.com
|
||||
</pre>
|
||||
|
||||
<h4>Download the contents of the page "example.com" resuming a previous attempt
|
||||
(<code>-C</code> flag)</h4>
|
||||
|
||||
<pre>
|
||||
curl -O -C example.com
|
||||
</pre>
|
||||
|
||||
|
||||
<h4>Do an HTTP DELETE request to "example.com" with a custom header
|
||||
(<code>-H</code> and <code>-X</code> flags)</h4>
|
||||
|
||||
<pre>
|
||||
curl -H 'User-Agent: Tamagotchi' -X DELETE example.com
|
||||
</pre>
|
||||
|
||||
<h4>Print to <em>stdout</em> "example.com" making a request with HTTP basic
|
||||
authentication (<code>-u</code> flag)</h4>
|
||||
|
||||
<pre>
|
||||
curl -u bob:P@ssw0rd example.com
|
||||
</pre>
|
40
site/pages/cmd/interm/watch.html
Normal file
40
site/pages/cmd/interm/watch.html
Normal file
|
@ -0,0 +1,40 @@
|
|||
---
|
||||
layout: page
|
||||
category-page: intermediate
|
||||
category-title: Intermediate commands
|
||||
tags: watch repeat track analyse seconds
|
||||
author: Claudio Maggioni
|
||||
title: watch
|
||||
---
|
||||
<p>
|
||||
The <code>watch</code> command is a system utility able to execute a command
|
||||
every <em>n</em> seconds by clearing the screen and displaying the
|
||||
output of the command each time the interval is over. This command is very
|
||||
simple to use and very effective: it can be used to check the size in bytes
|
||||
of a file while downloading it, or it can be used on <em>Linux</em> to jiggle
|
||||
around the mouse every ~5 minutes with the command <code>xdotool</code> in
|
||||
order to keep the computer awake.
|
||||
</p>
|
||||
|
||||
<h3>Usage</h3>
|
||||
|
||||
<p>
|
||||
<code>watch</code> has a very simple syntax: the amount in seconds to wait
|
||||
between executions is specified in seconds using the <code>-n</code> flag
|
||||
and the default value is <em>2</em>. Also, differences between older and
|
||||
newer outputs are highlighted if the <code>-d</code> flag is used.
|
||||
</p>
|
||||
|
||||
<h4>Watch the size of "ubuntu.iso" every 5 seconds</h4>
|
||||
|
||||
<pre>
|
||||
watch -n 5 du -h ubuntu.iso
|
||||
</pre>
|
||||
|
||||
<h4>Watch the contents of "site.html" every 2 seconds and highlight the
|
||||
differencies between iterations</h4>
|
||||
|
||||
<pre>
|
||||
watch -d cat site.html
|
||||
</pre>
|
||||
|
Loading…
Reference in a new issue