<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JoPa.Fr &#187; Scripts</title>
	<atom:link href="http://www.jopa.fr/index.php/category/scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jopa.fr</link>
	<description>001100010BIDOUILLE11101010111100010LIBRE1000100111100101</description>
	<lastBuildDate>Tue, 10 Jan 2012 21:59:31 +0000</lastBuildDate>
	<language>fr</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>DropBox, Ubuntu One, MyOne (unison) and Co</title>
		<link>http://www.jopa.fr/index.php/2010/06/08/dropbox-ubuntu-one-myone-unison-and-co/</link>
		<comments>http://www.jopa.fr/index.php/2010/06/08/dropbox-ubuntu-one-myone-unison-and-co/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 16:33:28 +0000</pubDate>
		<dc:creator>Jopa</dc:creator>
				<category><![CDATA[Astuces]]></category>
		<category><![CDATA[Réseau]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[fichiers]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Sauvegarde]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Serveur]]></category>

		<guid isPermaLink="false">http://www.jopa.fr/?p=1907</guid>
		<description><![CDATA[Les services de stockage en ligne, tels que Ubuntu One ou DropBox fleurissent depuis quelques temps sur la toile&#8230;  Il est vrai qu&#8217;ils s&#8217;avèrent bien pratiques, pour peu qu&#8217;on ne soit pas trop regardant sur les contraintes de sécurité. Ces deux applications sont très similaires et proposent, entre autre, un espace de stockage en ligne [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Les services de stockage en ligne, tels que <a title="Ubuntu One" href="https://one.ubuntu.com/" target="_blank">Ubuntu One</a> ou <a href="https://www.dropbox.com/referrals/NTc4MDgwODQ5" target="_blank">DropBox</a> fleurissent depuis quelques temps sur la toile&#8230;  Il est vrai qu&#8217;ils s&#8217;avèrent bien pratiques, pour peu qu&#8217;on ne soit pas trop regardant sur les contraintes de sécurité.</p>
<p style="text-align: center;"><a href="https://www.dropbox.com/referrals/NTc4MDgwODQ5"><img class="size-full wp-image-1924  aligncenter" title="logo_drop_box" src="http://www.jopa.fr/wp-content/uploads/2010/06/logo_drop_box.png" alt="" width="231" height="60" /></a></p>
<p style="text-align: justify;">Ces deux applications sont très similaires et proposent, entre autre, un espace de stockage en ligne de 2 Go, dans une version de base gratuite, ainsi que des options payantes permettant d&#8217;étendre la capacité à 50 Go ou plus. A ce jour, il faut compter un peu moins de 10 € par mois pour 50 Go. <a href="https://www.dropbox.com/referrals/NTc4MDgwODQ5" target="_blank">Dropbox</a> propose un système de parrainage qui vous fera gagner 250 Mo supplémentaires chaque fois que vous parrainez une nouvel inscrit (dans la limite de 8Go).</p>
<p style="text-align: justify;"><span id="more-1907"></span></p>
<p style="text-align: justify;">Les fichiers sont accessibles depuis n&#8217;importe quel ordinateur connecté à Internet via une interface web. Ceci n&#8217;est pas pour déplaire à Mamie,  qui se voit rassurée de pouvoir sauvegarder ses précieuses recettes de cuisine à l&#8217;abri d&#8217;un incendie ou de je ne sais quelle autre catastrophe domestique.</p>
<p style="text-align: center;"><a href="https://one.ubuntu.com/"><img class="aligncenter size-full wp-image-1912" title="ubuntu_one1" src="http://www.jopa.fr/wp-content/uploads/2010/06/ubuntu_one12.jpg" alt="" width="848" height="509" /></a></p>
<p style="text-align: justify;">L&#8217;installation d&#8217;un logiciel client sur un ou plusieurs postes va permettre de synchroniser un répertoire local avec l&#8217;espace de stockage en ligne. Ainsi, un fichier ajouté dans ce dossier sera automatiquement ajouté par synchronisation dans l&#8217;espace en ligne.  Ce dernier se synchronisera à son tour avec les autres machines sur lequel le client est installé. C&#8217;est très pratique pour Mamie, qui peut taper sa recette de cookies au chocolats sur l&#8217;ordinateur de son bureau et l&#8217;emporter à son club de cuisine sur son <em>Ipad</em> automatiquement synchronisé &#8211; Qu&#8217;elle frimeuse cette mamie &#8211;   Pour cela, je dois préciser qu&#8217;elle a une préférence pour <a href="https://www.dropbox.com/referrals/NTc4MDgwODQ5" target="_blank">DropBox</a>, porté sur de nombreux systèmes, contrairement à <a href="https://one.ubuntu.com/" target="_self">Ubuntu One</a>, qui reste encore limité à un environnement Ubuntu.</p>
<div class="mceTemp mceIEcenter">
<dl id="attachment_1937" class="wp-caption  aligncenter" style="width: 489px;">
<dt class="wp-caption-dt"><a href="https://www.dropbox.com/referrals/NTc4MDgwODQ5"><img class="size-full wp-image-1937  " title="tour_1" src="http://www.jopa.fr/wp-content/uploads/2010/06/tour_1.jpg" alt="Source : www.dropbox.com" width="479" height="380" /></a></dt>
</dl>
</div>
<p style="text-align: center;"><em>Image : Dropbox.com</em></p>
<p style="text-align: justify;">Enfin, parmi les multiples utilisations possibles, nous trouvons bien entendu la possibilité de partager des fichiers ou des dossiers avec d&#8217;autres utilisateurs. Très pratique pour Mamie, qui peut diffuser, à toute la famille, les photos de ses pâtisseries qu&#8217;elle prend en 10 MégaPixel grâce à son réflex numérique.</p>
<p style="text-align: center;"><a href="http://www.jopa.fr/wp-content/uploads/2010/06/Capture-jopa - Navigateur-de-fichiers.png"><img class="aligncenter size-full wp-image-1917" title="Capture-jopa - Navigateur de fichiers" src="http://www.jopa.fr/wp-content/uploads/2010/06/Capture-jopa - Navigateur-de-fichiers.png" alt="" width="584" height="358" /></a></p>
<p style="text-align: justify;">Outre la capacité limitée dans les versions gratuites, le fait que les fichiers soient stockés en clair, on ne sais où, peut-être perturbant. Il est bien sûr possible de chiffrer les données avant leur stockage, mais il faut bien avouer que ce n&#8217;est pas très pratique.</p>
<p style="text-align: justify;">Sachant que des outils libres, tels qu&#8217; <em><a title="Unison" href="http://www.cis.upenn.edu/~bcpierce/unison/" target="_blank">unison</a>, </em>on largement fait leurs preuves en matière de synchronisation, l&#8217;idée de construire ma propre architecture &laquo;&nbsp;JopaOne&nbsp;&raquo; m&#8217;a traversé l&#8217;esprit. C&#8217;est alors que je suis tombé sur <a href="http://kik-it.homelinux.org/index.php?entry=entry090918-131841" target="_blank">le tuto de KIK-IT : UbuntuOne VS MyOne</a>, décrivant exactement ce que je souhaitais faire : Un espace de stockage sur un de mes serveurs et des répertoires locaux sur mes différentes machines, le tout synchronisé grâce à <em>unision</em>,  de préférence à travers <em>ssh</em>&#8230;</p>
<p style="text-align: justify;">Pour conclure et je pense que Mamie sera d&#8217;accord avec moi, ma préférence va vers <em>DropBox </em>pour le partage de fichiers non sensibles avec les amis. Ce dernier est plus abouti qu&#8217;<em>Ubuntu One </em>et bien plus rapide pour  les synchronisation. La disponibilité du client sous de multiples plateforme est un de ses atouts majeurs&#8230; Mamie nous fait remarquer que le client &laquo;&nbsp;<a href="http://fr.wikipedia.org/wiki/Android">Androïd</a>&nbsp;&raquo; est très sympathique pour ajouter son Smartphone</p>
<p style="text-align: justify;">Pour la synchronisation de documents entre mes machines, j&#8217;ai préféré une solution basée sur <em>Unison et ssh&#8230; </em>Il n&#8217;y a pas a dire, on est bien plus tranquille quand les fichiers sont sur un serveur bien à nous&#8230;</p>
<p><strong>Liens : </strong></p>
<ul>
<li><a href="http://one.ubuntu.com/" target="_blank">Ubuntu One</a></li>
<li><a href="https://www.dropbox.com/referrals/NTc4MDgwODQ5" target="_blank">DropBox</a></li>
<li><a href="http://kik-it.homelinux.org/index.php?entry=entry090918-131841">MyOne (KIK-IT</a>)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.jopa.fr/index.php/2010/06/08/dropbox-ubuntu-one-myone-unison-and-co/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Mir:ror mon beau Mir:ror&#8230;Comment puis-je te comprendre ?</title>
		<link>http://www.jopa.fr/index.php/2009/07/12/violet-mirror-acces-device-c/</link>
		<comments>http://www.jopa.fr/index.php/2009/07/12/violet-mirror-acces-device-c/#comments</comments>
		<pubDate>Sun, 12 Jul 2009 00:22:12 +0000</pubDate>
		<dc:creator>Jopa</dc:creator>
				<category><![CDATA[Bidouilles]]></category>
		<category><![CDATA[Divers]]></category>
		<category><![CDATA[Planet-Libre]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Développement]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mir:ror]]></category>
		<category><![CDATA[rfid]]></category>

		<guid isPermaLink="false">http://www.jopa.fr/?p=1415</guid>
		<description><![CDATA[Dans mon précédent article, je présentais mir:ror, le petit lecteur RFID commercialisé par la société Violet.  Après avoir survolé leur application &#171;&#160;Mirware&#160;&#187; et mis en évidence les limites de son utilisation, je vais mettre &#171;&#160;les mains dans le cambouis&#160;&#187; pour essayer de comprendre comment communiquer avec Mir:ror.  L&#8217;idée étant de pouvoir coder de petits outils [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><img class="alignright size-medium wp-image-1437" title="miror" src="http://www.jopa.fr/wp-content/uploads/2009/07/miror-300x254.jpg" alt="miror" width="184" height="156" />Dans mon <a title="http://www.jopa.fr/index.php/2009/07/07/violet-mirror-linux" href="http://www.jopa.fr/index.php/2009/07/07/violet-mirror-linux">précédent article</a>, je présentais <em>mir:ror</em>, le petit lecteur RFID commercialisé par la société <a title="http://www.violet.net/" href="http://www.violet.net/">Violet</a>.  Après avoir survolé leur application &laquo;&nbsp;Mirware&nbsp;&raquo; et mis en évidence les limites de son utilisation, je vais mettre &laquo;&nbsp;les mains dans le cambouis&nbsp;&raquo; pour essayer de comprendre comment communiquer avec Mir:ror.  L&#8217;idée étant de pouvoir coder de petits outils capables de réagir à des tags RFID.</p>
<p style="text-align: justify;"><span id="more-1415"></span></p>
<p style="text-align: justify;">D&#8217;un point de vu système, Mir:ror est directement reconnu sous Linux et accessible via le handler de périphérique /dev/hidraw<em>X</em> (où <em>X</em> est le numéro de périphérique, normalement &laquo;&nbsp;0&#8243; si c&#8217;est le premier appareil du genre connecté).</p>
<p style="text-align: justify;">La petite application &laquo;&nbsp;<em>discover-device</em>&laquo;&nbsp;, fournie avec <em>Mirware</em>, permet de le détecter automatiquement :</p>
<p style="text-align: justify;"><img class="aligncenter size-full wp-image-1417" title="discover-device" src="http://www.jopa.fr/wp-content/uploads/2009/07/discover-device.png" alt="discover-device" width="457" height="246" /></p>
<p style="text-align: justify;">Attention tout de même aux droits, le périphérique n&#8217;est par défaut accessible que par <em>root</em>, il faudra lui changer les droits ou utiliser le script &laquo;&nbsp;<em>installer.sh</em>&nbsp;&raquo; pour le faire, avant de pouvoir l&#8217;exploiter avec un utilisateur standard.</p>
<p style="text-align: justify;">Commençons par voir ce qu&#8217;il se passe avec un simple &laquo;&nbsp;cat&nbsp;&raquo; du fichier :</p>
<p style="text-align: justify;"><img class="size-full wp-image-1421 aligncenter" title="cat-miror" src="http://www.jopa.fr/wp-content/uploads/2009/07/cat-miror.png" alt="cat-miror" width="457" height="246" /></p>
<p style="text-align: justify;">Des hiéroglyphes s&#8217;affichent lorsque nous approchons ou retirons un tag&#8230; C&#8217;est plutôt bon signe, et visiblement c&#8217;est binaire ! Nous devrions y voir plus clair avec un affichage en hexadécimal.  <em>Hexdump</em> est idéal pour ça !</p>
<p style="text-align: justify;"><img class="aligncenter size-full wp-image-1422" title="hexdump" src="http://www.jopa.fr/wp-content/uploads/2009/07/hexdump.png" alt="hexdump" width="457" height="246" /></p>
<p style="text-align: justify;">La première ligne (0000 0000 0000 0000 0000 0000 0000 0000 *) nous indique que tant qu&#8217;il ne se passe rien, on lit des zéros&#8230; Où&#8230;Qu&#8217;on lit des zéros tant qu&#8217;il ne se passe rien ! (c&#8217;est plutôt normal).<br />
Les deux lignes suivantes (0102 0000 d008 1a02 5303 4202 00d2 0000 &#8211; 0000 0000 0000 0000 0000 0000 0000 0000) s&#8217;affichent lorsqu&#8217;un tag est approché, les deux dernières ( 0202 0000 d008 1a02 5303 4202 00d2 0000 &#8211; 0000 0000 0000 0000 0000 0000 0000 0000 ) lorsqu&#8217;on éloigne le tag.</p>
<p style="text-align: justify;">Après plusieurs tests, j&#8217;en déduis assez facilement que les deux premiers octets (0102 ou 0202) codent l&#8217;évènement. J&#8217;en ai repéré 4 types :</p>
<ul style="text-align: justify;">
<li>0&#215;0102 : Tag rfid détecté,</li>
<li>0&#215;0202 : Tag rfid retiré,</li>
<li>0&#215;0501 : Le mir:ror est mis à l&#8217;envert,</li>
<li>0&#215;0401 : Le mir:ror est remis à l&#8217;endroit.</li>
</ul>
<p style="text-align: justify;">Les 12 octets suivants semblent identifier la puce RFID.</p>
<p style="text-align: justify;">A titre de test, écrivons rapidement un petit bout de code C, prenant le device en paramètre et affichant les évènements et le tag associé :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1415code5'); return false;">View Code</a> C</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p14155"><td class="code" id="p1415code5"><pre class="c" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Jopa - Petit test du Mir:ror : test_mirror.c</span>
<span style="color: #339933;">#include &lt;stdio.h&gt;</span>
<span style="color: #339933;">#include &lt;stdlib.h&gt;</span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> argc<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>argv<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  FILE <span style="color: #339933;">*</span>mirror<span style="color: #339933;">;</span>
  <span style="color: #993333;">short</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> block<span style="color: #339933;">;</span>
  <span style="color: #993333;">short</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> event<span style="color: #339933;">;</span>
  <span style="color: #993333;">char</span> tag<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">25</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #993333;">int</span> i<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//Vérification du paramètre (device)</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>argc<span style="color: #339933;">!=</span><span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">printf</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Usage : %s mirror_device <span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        exit<span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Ouverture du fichier device</span>
  mirror <span style="color: #339933;">=</span> fopen<span style="color: #009900;">&#40;</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;rb&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>mirror<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Accès à  %s impossible !<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        exit<span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Boucle en lecture</span>
  <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     fread<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>event<span style="color: #339933;">,</span><span style="color: #0000dd;">2</span><span style="color: #339933;">,</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span>mirror<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>event<span style="color: #339933;">!=</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// Evenement detecté, lecture de l'ID</span>
        <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span><span style="color: #0000dd;">6</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            fread<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>block<span style="color: #339933;">,</span><span style="color: #0000dd;">2</span><span style="color: #339933;">,</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span>mirror<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            sprintf<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>tag<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">*</span><span style="color: #0000dd;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;%04X&quot;</span><span style="color: #339933;">,</span>block<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
 <span style="color: #666666; font-style: italic;">//Affichage en fonction de l'événement</span>
        <span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">// Tag On</span>
            <span style="color: #b1b100;">case</span> <span style="color: #208080;">0x102</span> <span style="color: #339933;">:</span>
                <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s : ON<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>tag<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
             <span style="color: #666666; font-style: italic;">//Tag Off</span>
             <span style="color: #b1b100;">case</span> <span style="color: #208080;">0x202</span> <span style="color: #339933;">:</span>
                 <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s : OFF<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>tag<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                 <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
             <span style="color: #666666; font-style: italic;">//Mirror envers</span>
             <span style="color: #b1b100;">case</span> <span style="color: #208080;">0x501</span> <span style="color: #339933;">:</span>
                 <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;MIR:ROR ENVERS<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                 <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
             <span style="color: #666666; font-style: italic;">//Mirror endroit</span>
             <span style="color: #b1b100;">case</span> <span style="color: #208080;">0x401</span> <span style="color: #339933;">:</span>
                   <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;MIR:ROR ENDROIT<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
             <span style="color: #666666; font-style: italic;">//Default</span>
             <span style="color: #b1b100;">default</span> <span style="color: #339933;">:</span>
                   <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Evénement inconnu<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">//switch</span>
      <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">//if (event</span>
   <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">//while (1)</span>
<span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// main()</span></pre></td></tr></table></div>

<p style="text-align: justify;">En quelques lignes, nous ouvrons le périphérique dont le handler est passé en paramètre et bouclons sur sa lecture, 2 octets par 2 octets.<br />
Quand autre chose que &laquo;&nbsp;0&#8243; est détecté, c&#8217;est forcément un changement d&#8217;état. Nous lisons ensuite l&#8217;identifiant de la puce RFID.<br />
La dernière partie affiche un message en fonction de l&#8217;évènement détecté.</p>
<p style="text-align: justify;">Il ne reste plus qu&#8217;à le compiler et le tester :<br />
<span style="color: #800000;">$ gcc test_mirror.c -o test_mirror<br />
$ ./test_mirror</span></p>
<p><img class="aligncenter size-full wp-image-1434" title="test_mirror" src="http://www.jopa.fr/wp-content/uploads/2009/07/test_mirror.png" alt="test_mirror" width="497" height="331" /></p>
<p><span style="color: #800000;">Pour compléter l&#8217;exemple, nous pouvons rajouter l&#8217;exécution d&#8217;un script associé au tag et à son approche ou son éloignement. Les scripts pourraient être stockés dans le répertoire de l&#8217;utilisateur et porter l&#8217;<em>&lt;id&gt;-on.sh</em> ou l&#8217;<em>&lt;id&gt;-off.sh</em> comme nom. Pour l&#8217;exemple :</span></p>
<ul>
<li>0000D0081A025303420200D2-on.sh : Lancement de Firefox sur le blog de Jopa</li>
</ul>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1415code6'); return false;">View Code</a> SH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p14156"><td class="code" id="p1415code6"><pre class="sh" style="font-family:monospace;">#!/bin/sh
firefox http://www.jopa.fr</pre></td></tr></table></div>

<ul>
<li>0000D0081A025303420200D2-off.sh : Lancement de Thunderbird</li>
</ul>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1415code7'); return false;">View Code</a> SH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p14157"><td class="code" id="p1415code7"><pre class="sh" style="font-family:monospace;">#!/bin/sh
thunderbird</pre></td></tr></table></div>

<p><span style="color: #800000;">$ chmod +x ~/0000D0081A025303420200D2-*.sh</span></p>
<p style="text-align: justify;">Adaptons un peu le code en ajoutant une variable pour le nom du script et une commande &laquo;&nbsp;<em>system</em>&nbsp;&raquo; dans le <em>&laquo;&nbsp;switch/case&nbsp;&raquo;</em>.</p>
<p style="text-align: justify;">

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1415code8'); return false;">View Code</a> C</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p14158"><td class="code" id="p1415code8"><pre class="c" style="font-family:monospace;">   <span style="color: #666666; font-style: italic;">// Jopa - Test Mir:ror</span>
&nbsp;
<span style="color: #339933;">#include &lt;stdio.h&gt;</span>
<span style="color: #339933;">#include &lt;stdlib.h&gt;</span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> argc<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>argv<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  FILE <span style="color: #339933;">*</span>mirror<span style="color: #339933;">;</span>
  <span style="color: #993333;">short</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> block<span style="color: #339933;">;</span>
  <span style="color: #993333;">short</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> event<span style="color: #339933;">;</span>
  <span style="color: #993333;">char</span> tag<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">25</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">// Ajout d'un variable script</span>
  <span style="color: #993333;">char</span> script<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">256</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #993333;">int</span> i<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//Vérification du paramètre (device)</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>argc<span style="color: #339933;">!=</span><span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">printf</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Usage : %s mirror_device <span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        exit<span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Ouverture du fichier device</span>
  mirror <span style="color: #339933;">=</span> fopen<span style="color: #009900;">&#40;</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;rb&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>mirror<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Accès à  %s impossible !<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        exit<span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Boucle en lecture</span>
  <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     fread<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>event<span style="color: #339933;">,</span><span style="color: #0000dd;">2</span><span style="color: #339933;">,</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span>mirror<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>event<span style="color: #339933;">!=</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// Evenement detecté, lecture de l'ID</span>
        <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span><span style="color: #0000dd;">6</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            fread<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>block<span style="color: #339933;">,</span><span style="color: #0000dd;">2</span><span style="color: #339933;">,</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span>mirror<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            sprintf<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>tag<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">*</span><span style="color: #0000dd;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;%04X&quot;</span><span style="color: #339933;">,</span>block<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
 <span style="color: #666666; font-style: italic;">//Affichage en fonction de l'événement</span>
        <span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">// Tag On</span>
            <span style="color: #b1b100;">case</span> <span style="color: #208080;">0x102</span> <span style="color: #339933;">:</span>
                <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s : ON<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>tag<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #666666; font-style: italic;">//Construction du nom de script et exécution</span>
                sprintf<span style="color: #009900;">&#40;</span>script<span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;./%s-on.sh&quot;</span><span style="color: #339933;">,</span>tag<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                system<span style="color: #009900;">&#40;</span>script<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
             <span style="color: #666666; font-style: italic;">//Tag Off</span>
             <span style="color: #b1b100;">case</span> <span style="color: #208080;">0x202</span> <span style="color: #339933;">:</span>
                 <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s : OFF<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>tag<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                 <span style="color: #666666; font-style: italic;">//Construction du nom de script et exécution</span>
                 sprintf<span style="color: #009900;">&#40;</span>script<span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;./%s-off.sh&quot;</span><span style="color: #339933;">,</span>tag<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                 system<span style="color: #009900;">&#40;</span>script<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                 <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
             <span style="color: #666666; font-style: italic;">//Mirror envers</span>
             <span style="color: #b1b100;">case</span> <span style="color: #208080;">0x501</span> <span style="color: #339933;">:</span>
                 <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;MIR:ROR ENVERS<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                 <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
             <span style="color: #666666; font-style: italic;">//Mirror endroit</span>
             <span style="color: #b1b100;">case</span> <span style="color: #208080;">0x401</span> <span style="color: #339933;">:</span>
                   <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;MIR:ROR ENDROIT<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
             <span style="color: #666666; font-style: italic;">//Default</span>
             <span style="color: #b1b100;">default</span> <span style="color: #339933;">:</span>
                   <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Evénement inconnu&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">//switch</span>
      <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">//if (event</span>
   <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">//while (1)</span>
<span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// main()</span></pre></td></tr></table></div>

<p style="text-align: justify;">Ceci n&#8217;est bien entendu qu&#8217;un exemple, écrit rapidement et pas forcément très propre. Mais il permet de mettre en évidence la simplicité avec laquelle il est possible d&#8217;accéder à des informations RFID et ouvre la porte sur des développements qui peuvent être rapidement prometteurs.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jopa.fr/index.php/2009/07/12/violet-mirror-acces-device-c/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Fonera 2, te voilà !</title>
		<link>http://www.jopa.fr/index.php/2008/10/20/fonera-2-te-voila/</link>
		<comments>http://www.jopa.fr/index.php/2008/10/20/fonera-2-te-voila/#comments</comments>
		<pubDate>Mon, 20 Oct 2008 21:06:48 +0000</pubDate>
		<dc:creator>Jopa</dc:creator>
				<category><![CDATA[Bidouilles]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Fonera]]></category>

		<guid isPermaLink="false">http://www.jopa.fr/?p=613</guid>
		<description><![CDATA[En rentrant du bureau, un colis UPS facilement identifiable m&#8217;attendait sagement&#8230; Chouette ! Ma Fonera 2 ! Avant de tenter une install d&#8217;OpenWrt, je vais jeter un coup d&#8217;œil au Firmware FON. Celui préinstallé (2.0.1 r1 beta) n&#8217;apporte pas énormément de nouveautés. On y trouve la possibilité de monter et explorer des périphériques de stockage [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://www.jopa.fr/wp-content/uploads/2008/10/la_fonera_2_back.jpg"><img class="alignleft size-full wp-image-623" title="la_fonera_2_back" src="http://www.jopa.fr/wp-content/uploads/2008/10/la_fonera_2_back.jpg" alt="" width="170" height="180" /></a>En rentrant du bureau, un colis UPS facilement identifiable m&#8217;attendait sagement&#8230; Chouette ! Ma Fonera 2 ! Avant de tenter une install d&#8217;OpenWrt, je vais jeter un coup d&#8217;œil au Firmware FON. Celui préinstallé (2.0.1 r1 beta) n&#8217;apporte pas énormément de nouveautés. On y trouve la possibilité de monter et explorer des périphériques de stockage USB&#8230; C&#8217;est déjà bien, mais je m&#8217;attendais à plus&#8230;</p>
<p style="text-align: justify;">Je m&#8217;empresse de <a href="http://wiki.fon.com/wiki/La_Fonera_2.0#Firmware_Related_Downloads">télécharger une mise à jour</a> que j&#8217;installe très simplement via l&#8217;interface web.  C&#8217;est simple, mais qu&#8217;est-ce que c&#8217;est long !!!</p>
<p style="text-align: justify;">Donc&#8230; une vingtaine de minutes plus tard, me voici avec la version 2.1.0.1 du Firmware&#8230; Et là, on peut dire que ça change !!!</p>
<p style="text-align: justify;"><span id="more-613"></span></p>
<p style="text-align: justify;">Au niveau de l&#8217;USB, nous avons la possibilité d&#8217;activer des périphériques de stockages bien sûr, mais aussi de gérer des webcams, des scanners et des imprimantes.</p>
<p style="text-align: justify;"><a href="http://www.jopa.fr/wp-content/uploads/2008/10/file_browser1.png"><img class="aligncenter size-full wp-image-616" title="file_browser1" src="http://www.jopa.fr/wp-content/uploads/2008/10/file_browser1.png" alt="" width="500" height="299" /></a></p>
<p style="text-align: justify;">Les partitions montées peuvent ensuite être partagés via samba (partage pour les réseaux windows) et/ou via un serveur <em>ftp </em>intégré.</p>
<p style="text-align: justify;"><a href="http://www.jopa.fr/wp-content/uploads/2008/10/partage_win.png"><img class="aligncenter size-full wp-image-618" title="partage_win" src="http://www.jopa.fr/wp-content/uploads/2008/10/partage_win.png" alt="" width="500" height="303" /></a></p>
<p style="text-align: justify;">Je farfouille un peu dans mes tiroirs&#8230; Je dois bien avoir une webcam quelque part !</p>
<p style="text-align: justify;"><a href="http://www.jopa.fr/wp-content/uploads/2008/10/webcam1.png"><img class="aligncenter size-full wp-image-619" title="webcam1" src="http://www.jopa.fr/wp-content/uploads/2008/10/webcam1.png" alt="" width="500" height="284" /></a></p>
<p style="text-align: justify;">C&#8217;est plutôt sympa, j&#8217;ai la possibilité d&#8217;enregistrer des snapshots ( il faut pour cela q&#8217;un périphérique disque usb soit connecté)  ou de visionner le flux vidéo via le navigateur.</p>
<p style="text-align: justify;"><a href="http://www.jopa.fr/wp-content/uploads/2008/10/webcam3.png"><img class="aligncenter size-full wp-image-620" title="webcam3" src="http://www.jopa.fr/wp-content/uploads/2008/10/webcam3.png" alt="" width="500" height="467" /></a></p>
<p style="text-align: justify;">
<p style="text-align: justify;">Bouh&#8230;Je fais peur là non ? On dirait bien que ce petit joujou promet de bonnes heures de bidouilles&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jopa.fr/index.php/2008/10/20/fonera-2-te-voila/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Pas grub ? Réinstallation du bootloader quand ça boote plus&#8230;</title>
		<link>http://www.jopa.fr/index.php/2008/10/15/reinstallation-de-grub-debian-ou-ubuntu/</link>
		<comments>http://www.jopa.fr/index.php/2008/10/15/reinstallation-de-grub-debian-ou-ubuntu/#comments</comments>
		<pubDate>Tue, 14 Oct 2008 22:42:55 +0000</pubDate>
		<dc:creator>Jopa</dc:creator>
				<category><![CDATA[Astuces]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Boot]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.jopa.fr/?p=542</guid>
		<description><![CDATA[Suite à une installation foireuse en dual-boot (d&#8217;OpenSolaris pour tout vous dire), mon petit portable s&#8217;est retrouvé sans bootloader&#8230; Une occasion pour nous de voir comment réinstaller grub, sans réinstaller toute la machine&#8230; Dans un premier temps, nous aurons besoin d&#8217;un liveCD, peut importe la distribution, l&#8217;essentiel est d&#8217;obtenir un shell. Une fois la machine [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://www.jopa.fr/wp-content/uploads/2008/10/grub.jpg"><img class="alignleft size-medium wp-image-544" title="grub" src="http://www.jopa.fr/wp-content/uploads/2008/10/grub-300x180.jpg" alt="" width="300" height="180" /></a>Suite à une installation foireuse en dual-boot (d&#8217;OpenSolaris pour tout vous dire), mon petit portable s&#8217;est retrouvé sans <em>bootloader</em>&#8230; Une occasion pour nous de voir comment réinstaller grub, sans réinstaller toute la machine&#8230;</p>
<p style="text-align: justify;">Dans un premier temps, nous aurons besoin d&#8217;un liveCD, peut importe la distribution, l&#8217;essentiel est d&#8217;obtenir un shell.</p>
<p><span id="more-542"></span></p>
<p style="text-align: justify;">Une fois la machine bootée sur le CD, il nous faut préparer le chroot en montant la partition, <em>/proc </em>contenant les informations du noyau et  /<em>dev</em> pour l&#8217;accès au périphériques.</p>
<p style="text-align: justify;">Dans mon cas, la partition racine est sda1</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p542code11'); return false;">View Code</a> SH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p54211"><td class="code" id="p542code11"><pre class="sh" style="font-family:monospace;">mount /dev/sda1 /mnt
mount -t proc none /mnt/proc
mount -o bind /dev /mnt/dev</pre></td></tr></table></div>

<p style="text-align: justify;">Ceci fait, nous pouvons entrer dans le <em>chroot</em> et lancer les scripts d&#8217;installation de grub.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p542code12'); return false;">View Code</a> SH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p54212"><td class="code" id="p542code12"><pre class="sh" style="font-family:monospace;">chroot /mnt
grub-install --recheck
grub-install /dev/sda</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.jopa.fr/index.php/2008/10/15/reinstallation-de-grub-debian-ou-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ecrire un robot pour le web avec&#8230; Lynx</title>
		<link>http://www.jopa.fr/index.php/2008/10/03/ecrire-un-robot-web-lynx/</link>
		<comments>http://www.jopa.fr/index.php/2008/10/03/ecrire-un-robot-web-lynx/#comments</comments>
		<pubDate>Thu, 02 Oct 2008 22:02:07 +0000</pubDate>
		<dc:creator>Jopa</dc:creator>
				<category><![CDATA[Astuces]]></category>
		<category><![CDATA[Planet-Libre]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Script]]></category>

		<guid isPermaLink="false">http://www.jopa.fr/?p=241</guid>
		<description><![CDATA[Boursicoteur à mes heures perdues, je m&#8217;intéresse surtout aux méthodes d&#8217;analyse graphique et aux traitements statistiques. J&#8217;utilise pour cela une base de données que j&#8217;alimente régulièrement avec les dernières cotations boursières. Le site ABCBourse fournit gratuitement ces valeurs sous forme d&#8217;un fichier csv, téléchargeable par l&#8217;intermédiaire d&#8217;un formulaire. Ce dernier permet de spécifier la période [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.jopa.fr/wp-content/uploads/2008/09/robot1.png"><img class="alignleft size-full wp-image-289" title="robot1" src="http://www.jopa.fr/wp-content/uploads/2008/09/robot1.png" alt="" width="150" height="163" /></a></p>
<p style="text-align: justify;">Boursicoteur à mes heures perdues, je m&#8217;intéresse surtout aux méthodes d&#8217;analyse graphique et aux traitements statistiques. J&#8217;utilise pour cela une base de données que j&#8217;alimente régulièrement avec les dernières cotations boursières.</p>
<p style="text-align: justify;">Le site <a title="AbcBourse" href="http://www.abcbourse.com">ABCBourse</a> fournit gratuitement ces valeurs sous forme d&#8217;un fichier <em>csv</em>, téléchargeable par l&#8217;intermédiaire d&#8217;un formulaire. Ce dernier permet de  spécifier la période et les catégories de valeurs souhaitées : <a title="http://download.abcbourse.com/historiques.aspx?f=ex" href="http://download.abcbourse.com/historiques.aspx?f=ex">http://download.abcbourse.com/historiques.aspx?f=ex</a></p>
<p style="text-align: justify;">Pour corser un peu l&#8217;énoncé, le site n&#8217;autorise pas le téléchargement de l&#8217;intégralité des valeurs en une seule fois, si la période dépasse la journée. L&#8217;objectif de cet article, vous l&#8217;aurez compris, est de montrer comment automatiser la récupération de ces valeurs au jour le jour, en vue de leur intégration dans une base <em>mysql</em>.</p>
<p style="text-align: justify;"><span id="more-241"></span></p>
<p style="text-align: left;">
<p style="text-align: justify;">
<p style="text-align: center;"><a href="http://www.jopa.fr/wp-content/uploads/2008/09/formabc.jpg"><img class="size-medium wp-image-242 aligncenter" title="formabc" src="http://www.jopa.fr/wp-content/uploads/2008/09/formabc-300x288.jpg" alt="" width="300" height="288" /></a></p>
<p style="text-align: justify;"><em>Lynx</em>, le navigateur en mode texte bien connu de tout geek qui se respecte, dispose d&#8217;une option très intéressante : il permet l&#8217;enregistrement de toutes les touches pressées lors de la navigation.  Le fichier ainsi obtenu pourra ensuite être rejoué, un peu comme une macro.</p>
<p style="text-align: justify;">En remplaçant dans ce fichier les dates saisies pour le formulaire par les dates souhaitées, le tour est joué&#8230;</p>
<p style="text-align: justify;">Allez&#8230; Zou !!!</p>
<h2 style="text-align: justify;">Etape 1 : Ca tourne !</h2>
<pre style="text-align: left;"><span style="color: #800000;">$ lynx  -accept_all_cookies -cmd_log=abc.log 

http://download.abcbourse.com/historiques.aspx?f=ex</span></pre>
<p style="text-align: left;">
<dl id="attachment_244" class="wp-caption alignnone" style="width: 510px; text-align: center;">
<dt class="wp-caption-dt"><a href="http://www.jopa.fr/wp-content/uploads/2008/09/lynx1.png"><img class="size-full wp-image-244" title="lynx1" src="http://www.jopa.fr/wp-content/uploads/2008/09/lynx1.png" alt="Formulaire ABCBourse" width="500" height="419" /></a></dt>
</dl>
<p style="text-align: justify;">Complétons le formulaire en prenant soin de bien saisir la date de début, la date de fin et de cocher les catégories de valeurs souhaitées. Un ou deux essais peuvent s&#8217;avérer nécessaires  quand on n&#8217;est pas familiarisé avec ce type de navigateur&#8230;</p>
<p style="text-align: justify;">Un &laquo;&nbsp;pseudo clic&nbsp;&raquo; sur le bouton &laquo;&nbsp;Submit&nbsp;&raquo; (marqué <em>[Télécharger.gif]-Submit</em>), la liste des actions et leurs cours apparaît.</p>
<div class="mceTemp mceIEcenter" style="text-align: center;">
<dl id="attachment_246" class="wp-caption aligncenter" style="width: 510px;">
<dt class="wp-caption-dt"><a href="http://www.jopa.fr/wp-content/uploads/2008/09/lynx2.png"><img class="size-full wp-image-246" title="lynx2" src="http://www.jopa.fr/wp-content/uploads/2008/09/lynx2.png" alt="Lynx 2" width="500" height="419" /></a></dt>
</dl>
</div>
<p style="text-align: justify;">La touche &laquo;&nbsp;<strong><em>p</em></strong>&nbsp;&raquo; permet d&#8217;accéder au menu d&#8217;impression. Ce menu permet également d&#8217;enregistrer la page dans un fichier. Le nom du fichier par défaut est de la forme <em>Cotations</em>[aaaammjj].txt; Très bien ça !</p>
<p style="text-align: center;"><img src="file:///C:/DOCUME~1/PASTRE~1/LOCALS~1/Temp/moz-screenshot.jpg" alt="" /></p>
<div class="mceTemp mceIEcenter" style="text-align: center;">
<dl id="attachment_247" class="wp-caption aligncenter" style="width: 510px;">
<dt class="wp-caption-dt"><a href="http://www.jopa.fr/wp-content/uploads/2008/09/lynx3.png"><img class="size-full wp-image-247" title="lynx3" src="http://www.jopa.fr/wp-content/uploads/2008/09/lynx3.png" alt="Lynx 3" width="500" height="434" /></a></dt>
<dd class="wp-caption-dd"> </dd>
</dl>
</div>
<p style="text-align: justify;">Nous pouvons quitter Lynx, c&#8217;est dans la boîte ! La séquence de touches est enregistrée dans le fichier <em>abc.log</em> .</p>
<p style="text-align: justify;">Pour vérifier son enregistrement, nous pouvons directement rejouer la &laquo;&nbsp;scène&nbsp;&raquo; :</p>
<pre style="text-align: justify;"><span style="color: #800000;">lynx  -accept_all_cookies -cmd_script=abc.log 

http://download.abcbourse.com/historiques.aspx?f=ex</span></pre>
<h2 style="text-align: justify;">Etape 2 : Le montage</h2>
<p style="text-align: left;">
<p style="text-align: justify;">Editons maintenant le fichier <em>abc.log</em>. L&#8217;exercice va consister à repérer les dates et à remplacer leurs chiffres par des balises qui seront exploitables par un script.  Je choisis arbitrairement :</p>
<ul>
<li>XXJ1 XXJ2 pour les deux chiffres du jour</li>
<li>XXM1 XXM2 pour les deux chiffres du mois</li>
<li>XXA1 XXA2 XXA3 XXA4 pour les quatre chiffres de l&#8217;année</li>
</ul>
<p>$ vi abc.log</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p241code16'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24116"><td class="code" id="p241code16"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># Command logfile created by Lynx 2.8.5rel.1 (04 Feb 2004)</span>
<span style="color: #808080; font-style: italic;"># Arg0 = lynx</span>
<span style="color: #808080; font-style: italic;"># Arg1 = -accept_all_cookies</span>
<span style="color: #808080; font-style: italic;"># Arg2 = -cmd_log=abc.log</span>
<span style="color: #808080; font-style: italic;"># Arg3 = http://download.abcbourse.com/historiques.aspx?f=ex</span>
<span style="color: #0066CC;">key</span> <span style="color: #66cc66;">&lt;</span>Down Arrow<span style="color: #66cc66;">&gt;</span>
<span style="color: #0066CC;">key</span> <span style="color: #66cc66;">&lt;</span>Down Arrow<span style="color: #66cc66;">&gt;</span>
<span style="color: #0066CC;">key</span> <span style="color: #66cc66;">&lt;</span>Down Arrow<span style="color: #66cc66;">&gt;</span>
...
<span style="color: #0066CC;">key</span> <span style="color: #66cc66;">&lt;</span>delete<span style="color: #66cc66;">&gt;</span>
<span style="color: #0066CC;">key</span> <span style="color: #66cc66;">&lt;</span>delete<span style="color: #66cc66;">&gt;</span>
<span style="color: #0066CC;">key</span> <span style="color: #66cc66;">&lt;</span>delete<span style="color: #66cc66;">&gt;</span>
<span style="color: #808080; font-style: italic;"># Ici le jour de début</span>
<span style="color: #808080; font-style: italic;"># key 2</span>
<span style="color: #808080; font-style: italic;"># key 3</span>
<span style="color: #0066CC;">key</span> XXJ1
<span style="color: #0066CC;">key</span> XXJ2
<span style="color: #0066CC;">key</span> <span style="color: #66cc66;">/</span>
<span style="color: #808080; font-style: italic;"># Ici le mois de début</span>
<span style="color: #808080; font-style: italic;"># key 0</span>
<span style="color: #808080; font-style: italic;"># key 9</span>
<span style="color: #0066CC;">key</span> XXM1
<span style="color: #0066CC;">key</span> XXM2
<span style="color: #0066CC;">key</span> <span style="color: #66cc66;">/</span>
<span style="color: #808080; font-style: italic;"># Ici l'année de début</span>
<span style="color: #808080; font-style: italic;"># key 2</span>
<span style="color: #808080; font-style: italic;"># key 0</span>
<span style="color: #808080; font-style: italic;"># key 0</span>
<span style="color: #808080; font-style: italic;"># key 8</span>
<span style="color: #0066CC;">key</span> XXA1
<span style="color: #0066CC;">key</span> XXA2
<span style="color: #0066CC;">key</span> XXA3
<span style="color: #0066CC;">key</span> XXA4
<span style="color: #0066CC;">key</span> <span style="color: #66cc66;">&lt;</span>Right Arrow<span style="color: #66cc66;">&gt;</span>
<span style="color: #0066CC;">key</span> <span style="color: #66cc66;">&lt;</span>delete<span style="color: #66cc66;">&gt;</span>
<span style="color: #0066CC;">key</span> <span style="color: #66cc66;">&lt;</span>delete<span style="color: #66cc66;">&gt;</span>
<span style="color: #0066CC;">key</span> <span style="color: #66cc66;">&lt;</span>delete<span style="color: #66cc66;">&gt;</span>
...
<span style="color: #808080; font-style: italic;"># Ici le jour de fin</span>
<span style="color: #808080; font-style: italic;"># key 2</span>
<span style="color: #808080; font-style: italic;"># key 3</span>
<span style="color: #0066CC;">key</span> XXJ1
<span style="color: #0066CC;">key</span> XXJ2
<span style="color: #0066CC;">key</span> <span style="color: #66cc66;">/</span>
<span style="color: #808080; font-style: italic;"># Ici le mois de fin</span>
<span style="color: #808080; font-style: italic;"># key 0</span>
<span style="color: #808080; font-style: italic;"># key 9</span>
<span style="color: #0066CC;">key</span> XXM1
<span style="color: #0066CC;">key</span> XXM2
<span style="color: #0066CC;">key</span> <span style="color: #66cc66;">/</span>
<span style="color: #808080; font-style: italic;"># Ici l'année de fin</span>
<span style="color: #808080; font-style: italic;"># key 2</span>
<span style="color: #808080; font-style: italic;"># key 0</span>
<span style="color: #808080; font-style: italic;"># key 0</span>
<span style="color: #808080; font-style: italic;"># key 8</span>
<span style="color: #0066CC;">key</span> XXA1
<span style="color: #0066CC;">key</span> XXA2
<span style="color: #0066CC;">key</span> XXA3
<span style="color: #0066CC;">key</span> XXA4
<span style="color: #0066CC;">key</span> <span style="color: #66cc66;">&lt;</span>Down Arrow<span style="color: #66cc66;">&gt;</span>
<span style="color: #0066CC;">key</span> <span style="color: #66cc66;">&lt;</span>Down Arrow<span style="color: #66cc66;">&gt;</span>
...
<span style="color: #0066CC;">key</span> <span style="color: #66cc66;">&lt;</span>Left Arrow<span style="color: #66cc66;">&gt;</span>
<span style="color: #0066CC;">key</span> <span style="color: #66cc66;">&lt;</span>Left Arrow<span style="color: #66cc66;">&gt;</span>
<span style="color: #0066CC;">key</span> <span style="color: #66cc66;">/</span>
<span style="color: #0066CC;">key</span> t
<span style="color: #0066CC;">key</span> m
<span style="color: #0066CC;">key</span> p
<span style="color: #0066CC;">key</span> <span style="color: #66cc66;">/</span>
<span style="color: #0066CC;">key</span> ^J
<span style="color: #0066CC;">key</span> o
<span style="color: #0066CC;">key</span> q
<span style="color: #0066CC;">key</span> o</pre></td></tr></table></div>

<h3>Etape 3 : Le script</h3>
<p style="text-align: left;">
<p style="text-align: justify;">Il ne reste plus qu&#8217;à réaliser un script <em>bash</em> qui remplacera les balises XXJ1 à XXA4 par les chiffres de la date du jour, exécutera lynx avec sa nouvelle séquence de commandes et finalement, déclenchera l&#8217;importation dans la base de données.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p241code17'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24117"><td class="code" id="p241code17"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Récupération de la date du jour</span>
<span style="color: #007800;">JOUR</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> <span style="color: #ff0000;">&quot;+%d/%m/%Y&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># &quot;Explode&quot; de la date en chiffres</span>
<span style="color: #007800;">J1</span>=<span style="color: #800000;">${JOUR:0:1}</span>
<span style="color: #007800;">J2</span>=<span style="color: #800000;">${JOUR:1:1}</span>
&nbsp;
<span style="color: #007800;">M1</span>=<span style="color: #800000;">${JOUR:3:1}</span>
<span style="color: #007800;">M2</span>=<span style="color: #800000;">${JOUR:4:1}</span>
&nbsp;
<span style="color: #007800;">A1</span>=<span style="color: #800000;">${JOUR:6:1}</span>
<span style="color: #007800;">A2</span>=<span style="color: #800000;">${JOUR:7:1}</span>
<span style="color: #007800;">A3</span>=<span style="color: #800000;">${JOUR:8:1}</span>
<span style="color: #007800;">A4</span>=<span style="color: #800000;">${JOUR:9:1}</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Construction du nouveau fichier de commande</span>
<span style="color: #666666; font-style: italic;"># La variable PART sert à construire le nom de la Balise (XX$PART)</span>
<span style="color: #666666; font-style: italic;"># Et de &quot;pointeur&quot; vers les variables $J1, $J2, etc... ($$PART)</span>
&nbsp;
<span style="color: #007800;">CMD</span>=<span style="color: #ff0000;">&quot;cat abc.log&quot;</span>
<span style="color: #000000; font-weight: bold;">for</span> PART <span style="color: #000000; font-weight: bold;">in</span> J1 J2 M1 M2 A1 A2 A3 A4; <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #7a0874; font-weight: bold;">eval</span> <span style="color: #007800;">CHIFFRE</span>=$<span style="color: #007800;">$PART</span>
    <span style="color: #007800;">CMD</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$CMD</span>|sed 's/XX<span style="color: #007800;">$PART</span>/<span style="color: #007800;">$CHIFFRE</span>/g'&quot;</span>
<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #007800;">CMD</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$CMD</span> &gt; /tmp/abc.cmd&quot;</span>
<span style="color: #7a0874; font-weight: bold;">eval</span> <span style="color: #007800;">$CMD</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Exécution de Lynx</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">lynx</span>  -accept_all_cookies -cmd_script=<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>abc.cmd http:<span style="color: #000000; font-weight: bold;">//</span>download.abcbourse.com<span style="color: #000000; font-weight: bold;">/</span>historiques.aspx?<span style="color: #007800;">f</span>=ex <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>cotationabc.log
&nbsp;
<span style="color: #666666; font-style: italic;"># Appel du script d'import dans la base</span>
<span style="color: #007800;">FICHIER</span>=<span style="color: #ff0000;">&quot;Cotations<span style="color: #007800;">$A1</span><span style="color: #007800;">$A2</span><span style="color: #007800;">$A3</span><span style="color: #007800;">$A4</span><span style="color: #007800;">$M1</span><span style="color: #007800;">$M2</span><span style="color: #007800;">$J1</span><span style="color: #007800;">$J2</span>.txt&quot;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-e</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$FICHIER</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    php import_batch.php <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$FICHIER</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>cotationabc.log
    <span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-n</span> <span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>cotationabc.log
    <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$FICHIER</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>cotations
<span style="color: #000000; font-weight: bold;">else</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;!!! Erreur de traitement du fichier <span style="color: #007800;">$FICHIER</span> !!!&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></td></tr></table></div>

<p style="text-align: justify;">Le lancement du script sera planifié dans un <em>crontab</em> afin de parfaire l&#8217;automatisation.</p>
<p style="text-align: justify;">A titre d&#8217;exemple, voici le script <strong><em>import_batch.php</em></strong> qui se charge d&#8217;importer les valeurs dans la base de données. Il est très réduit car il utilise une classe <em>fcours</em> &laquo;&nbsp;maison&nbsp;&raquo; possédant les attributs nécessaires à l&#8217;enregistrement de cotations boursières et une méthode d&#8217;import à partir d&#8217;un fichier. L&#8217;intérêt de l&#8217;article ne résident pas dans cette partie, je ne vais pas la détailler.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p241code18'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24118"><td class="code" id="p241code18"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/php -q
</span><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">include_once</span> <span style="color: #0000ff;">&quot;include/class_file_cours_inc.php&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$argc</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">||</span> <span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$argv</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'--help'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'-help'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'-h'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'-?'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
Script d<span style="color: #0000ff;">'import de données dans la base bourse...
&nbsp;
  Usage:
    &lt;?php echo $argv[0]; ?&gt; &lt;nomdefichier&gt;
&nbsp;
     &lt;nomdefichier&gt;  Nom du fichier CSV issu d'</span>ABCBourse au format Excel <span style="color: #339933;">/</span> ISIN
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
          <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Traitement du fichier <span style="color: #006699; font-weight: bold;">$argv[1]</span>n&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$import</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> amdr_fcours<span style="color: #009900;">&#40;</span><span style="color: #000088;">$argv</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$import</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">import</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.jopa.fr/index.php/2008/10/03/ecrire-un-robot-web-lynx/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Multitail&#8230; tail multiple</title>
		<link>http://www.jopa.fr/index.php/2008/09/24/multitail/</link>
		<comments>http://www.jopa.fr/index.php/2008/09/24/multitail/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 01:33:23 +0000</pubDate>
		<dc:creator>Jopa</dc:creator>
				<category><![CDATA[Astuces]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.jopa.fr/?p=194</guid>
		<description><![CDATA[Tous les administrateurs systèmes connaissent bien la commande tail qui permet de lister dynamiquement les dernières lignes d&#8217;un fichier. C&#8217;est un outil incontournable pour la surveillance de journaux systèmes en temps réel. &#171;&#160;Multitail&#160;&#187; réalise la même chose, mais en mieux ! Son principal intérêt réside dans la possibilité de traiter plusieurs fichiers en même temps, [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-medium wp-image-196" title="multitail" src="http://www.jopa.fr/wp-content/uploads/2008/09/multitail-300x216.png" alt="" width="300" height="216" /></p>
<p style="text-align: justify;">Tous les administrateurs systèmes connaissent bien la commande <em>tail</em> qui permet de lister dynamiquement les dernières lignes d&#8217;un fichier. C&#8217;est un outil incontournable pour la surveillance de journaux systèmes en temps réel.</p>
<p style="text-align: justify;"><em>&laquo;&nbsp;Multitail&nbsp;&raquo; </em>réalise la même chose, mais en mieux ! Son principal intérêt réside dans la possibilité de traiter plusieurs fichiers en même temps, la console étant tout simplement divisé par le nombre de fichiers ouverts. La coloration syntaxique, la possibilité de marquer des lignes ou encore d&#8217;effectuer des recherches sont des petits plus qui deviennent vite incontournables.</p>
<p style="text-align: justify;">Adopter <em>Multitail</em>, c&#8217;est finir de jongler entre les consoles et épargner les pauvres touches  [Alt], [F1], [F2], [F3],&#8230; du clavier.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jopa.fr/index.php/2008/09/24/multitail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sauvegardes par &#171;&#160;snapshots&#160;&#187; &#8211; La puissance de rsync et des liens durs</title>
		<link>http://www.jopa.fr/index.php/2008/03/18/sauvegardes-differentielles-la-puissance-de-rsync-et-des-liens-durs/</link>
		<comments>http://www.jopa.fr/index.php/2008/03/18/sauvegardes-differentielles-la-puissance-de-rsync-et-des-liens-durs/#comments</comments>
		<pubDate>Tue, 18 Mar 2008 22:00:42 +0000</pubDate>
		<dc:creator>Jopa</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Disque dur]]></category>
		<category><![CDATA[Sauvegarde]]></category>

		<guid isPermaLink="false">http://www.jopa.fr/?p=23</guid>
		<description><![CDATA[Je stocke une quantité inimaginable de scripts, de bouts de codes, de documents, de photos et de projets en tout genre sur mon serveur de fichiers. Quelques Go qui représentent des années de ma vie &#171;&#160;numérique&#160;&#187;. Le temps passe, le volume des données augmente et il devient urgent de trouver un moyen de sauvegarde plus [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.jopa.fr/wp-content/uploads/2008/03/sauvegardes.jpg" alt="Sauvegardes" align="left" /></p>
<p align="justify">Je stocke une quantité inimaginable de scripts, de bouts de codes, de documents, de photos et de projets en tout genre sur mon serveur de fichiers. Quelques Go qui représentent des années de ma vie &laquo;&nbsp;numérique&nbsp;&raquo;. Le temps passe, le volume des données augmente et il devient urgent de trouver un moyen de sauvegarde plus rapide, plus efficace et surtout moins fastidieux que la gravure sur DVD. <span style="color: #808080;">- Vous remarquerez au passage la photo prise en exclusivité pour l&#8217;illustration de cet article et sa superbe mise en scène réalisée sur le plan de travail de ma cuisine -</span><br />
La sauvegarde sur DAT ou DLT étant bien trop onéreuse et surtout trop lente, j&#8217;ai opté pour le montage d&#8217;un serveur de sauvegardes &laquo;&nbsp;maison&nbsp;&raquo;.</p>
<p><span id="more-23"></span></p>
<h3>Mise en place :</h3>
<p>* Côté matériel, un petit Céléron 900Mhz de récupération fera très bien l&#8217;affaire. Je le gonfle un peu en montant la ram à 384Mo et attribue le gros du budget au stockage en lui offrant deux beaux disques dur IDE de 320Go  <span style="color: #808080;">-  Ca ! C&#8217;est classe ! -<br />
</span><br />
* Côté logiciel, une distribution Debian et un petit script qui combine <em>rsync</em> pour optimiser les transferts réseaux et des liens durs pour garder un historique en limitant l&#8217;espace disque utilisé.</p>
<p align="justify">Pour simplifier les choses, nous allons appeler le serveur de fichiers &laquo;&nbsp;<em><strong>serv_file</strong></em>&nbsp;&raquo; et le serveur de sauvegardes &laquo;&nbsp;<em><strong>serv_nas</strong></em>&laquo;&nbsp;.</p>
<p align="justify">Les présentations étant faites, commençons par générer un bi-clés pour <em>ssh</em> sur <strong><em>serv_nas</em> </strong>et faire une copie de la clef publique sur <strong><em>serv_file</em></strong>, pour que mon premier puisse parler à<em> </em>mon second<em>, </em>via <em>ssh</em> et sans avoir à fournir de mot de passe. C&#8217;est quand même bien plus pratique pour automatiser le bazar !</p>
<p>Concrètement,  comment fait-on ?<br />
Sur <strong><em>serv_nas</em></strong> :</p>
<blockquote>
<pre><strong>srv_nas:~# ssh-keygen</strong>
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
/root/.ssh/id_rsa already exists.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
2d:40:c4:09:67:06:...b:bf:06 root@srv_nas</pre>
</blockquote>
<blockquote>
<pre><strong>srv_nas:~# ssh-copy-id root@srv_file</strong>
root@srv_file's password :</pre>
</blockquote>
<p>Tout c&#8217;est bien passé ?  L&#8217;ouverture d&#8217;une session ssh de <strong><em>serv_nas</em></strong> vers <strong><em>serv_file</em></strong> devrait se faire sans mot de passe. Essayons&#8230;</p>
<blockquote>
<pre><strong>srv_nas:~# ssh srv_file</strong>
Last login: Mon Mar 17 18:10:25 2008 from 192.168.7.102
Linux srv_file 2.6.18-6-686 #1 SMP Sun Feb 10 22:11:31 UTC 2008 i686</pre>
<pre>The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.</pre>
<pre>Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.</pre>
<pre>srv_file:~#
<strong>srv_file:~# exit</strong>

srv_nas~#</pre>
</blockquote>
<p>Si ce n&#8217;est pas déjà fait, il faut maintenant installer rsync sur les deux machines :</p>
<blockquote>
<pre><strong>srv_nas:~# aptitude install rsync
srv_nas:~# ssh srv_file aptitude install rsync</strong></pre>
</blockquote>
<h3>Le script &#8211; Initialisation</h3>
<p align="justify">Allez ! Fini la rigolade, passons au script&#8230;<br />
La première chose à faire est de déclarer quelques variables&#8230;C&#8217;est quand bien plus propre et ça facilite la modification du script par la suite.</p>
<ul>
<li>le nom serveur à sauvegarder (<strong>$SERVER</strong>),</li>
<li>le répetoire local de stockage des sauvegardes (<strong>$DST</strong>),</li>
<li>le fichier de log (<strong>$LOG</strong>),</li>
<li> et une date formatée qui va être utilisée pour &laquo;&nbsp;horodater&nbsp;&raquo; la sauvegarde (<strong>$DATE</strong>).</li>
</ul>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p23code23'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2323"><td class="code" id="p23code23"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;">#------Début du fichier /usr/local/scripts/snapshot.sh</span>
&nbsp;
<span style="color: #007800;">SERVEUR</span>=<span style="color: #ff0000;">&quot;srv_file&quot;</span>
<span style="color: #007800;">DST</span>=<span style="color: #ff0000;">&quot;/srv/sauvegardes&quot;</span>
<span style="color: #007800;">LOG</span>=<span style="color: #ff0000;">&quot;/var/log/snapshot-<span style="color: #007800;">$SERVEUR</span>.log&quot;</span>
<span style="color: #007800;">DATE</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>y<span style="color: #000000; font-weight: bold;">%</span>m<span style="color: #000000; font-weight: bold;">%</span>d-<span style="color: #000000; font-weight: bold;">%</span>H<span style="color: #000000; font-weight: bold;">%</span>M<span style="color: #000000; font-weight: bold;">`</span></pre></td></tr></table></div>

<h3>Le script &#8211; rsync :</h3>
<p align="justify">L&#8217;étape suivante, va consister à boucler sur les répertoires à sauvegarder (etc, home, root, data, srv et var dans l&#8217;exemple) pour en faire un miroir dans un dossier local nommé &laquo;&nbsp;<em>current</em>&nbsp;&raquo; (/srv/sauvegardes/current). Ce dernier contiendra toujours la dernière image des fichiers sauvegardés.<br />
La commande <em>rsync</em> avec les options suivantes est la plus à même de réaliser ce travail :</p>
<ul>
<li>-r  (récursif) pour inclure les sous répertoires,</li>
<li>-a  (archive) pour conserver les propriétés et les droits du fichier original,</li>
<li>&#8211;delete pour supprimer du répertoire destination tout fichier qui ne serait plus présent dans le répertoire source. Cette option est impérative pour la suite des opérations.</li>
</ul>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p23code24'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2324"><td class="code" id="p23code24"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># SYNCHRONISATION</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Début de la sauvegarde le <span style="color: #780078;">`date +%D`</span> à <span style="color: #780078;">`date +%H:%M`</span> &quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOG</span>
<span style="color: #000000; font-weight: bold;">for</span> REP <span style="color: #000000; font-weight: bold;">in</span> etc home root data srv var ;  <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;    *    Sauvegarde de  <span style="color: #007800;">$REP</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOG</span>
    rsync <span style="color: #660033;">-ra</span> <span style="color: #660033;">--delete</span> <span style="color: #007800;">$SERVEUR</span>:<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$REP</span> <span style="color: #007800;">$DST</span><span style="color: #000000; font-weight: bold;">/</span>current <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOG</span>
<span style="color: #000000; font-weight: bold;">done</span>;</pre></td></tr></table></div>

<p align="justify">Le grand intérêt dans l&#8217;utilisation de la commande <em>rsync</em> réside dans le fait que, contrairement à <em>scp</em>, elle ne va copier que les fichiers différents ou inexistants dans le répertoire destination et donc procurer un immense gain de bande passante et de temps.</p>
<h3>Le script &#8211; Les liens durs :</h3>
<p align="justify">La dernière étape va créer une image datée du répertoire <em>&laquo;&nbsp;current&nbsp;&raquo;</em>, avant que la prochaine synchronisation ne vienne en altérer le contenu, en optimisant l&#8217;espace disque utilisé.</p>
<p align="justify">Pour cette opération, la puissante des <em>liens dur</em>s va nous être très utile.</p>
<p align="justify"><span style="color: #800000;">Les<strong><em> liens durs </em></strong>associent deux ou plusieurs fichiers à un même espace sur le disque. Les deux fichiers restent indépendants, tout en partageant le même espace disque et donc le même inode . Toute modification de l&#8217;un, modifie l&#8217;autre, mais la suppression de l&#8217;un, casse le lien et ne supprime pas physiquement l&#8217;autre.</span></p>
<p align="justify">Dans notre cas, nous allons créer un lien dur de notre dossier &laquo;&nbsp;current&nbsp;&raquo; et de son contenu vers un dossier portant la valeur de notre variable $DATE (la date et l&#8217;heure du début de la sauvegarde).<br />
Il suffit pour cela d&#8217;utiliser la commande &laquo;&nbsp;<em>cp</em>&nbsp;&raquo;  avec les options :</p>
<ul>
<li>-l  (lien) pour la copie par lien dur,</li>
<li>-a  (archive) pour conserver les propriétés et droits des fichiers.</li>
</ul>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p23code25'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2325"><td class="code" id="p23code25"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># SNAPSHOT</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-al</span> <span style="color: #007800;">$DST</span><span style="color: #000000; font-weight: bold;">/</span>current <span style="color: #007800;">$DST</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$DATE</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOG</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Fin de la sauvegarde le <span style="color: #780078;">`date +%D`</span> à <span style="color: #780078;">`date +%H:%M`</span> &quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOG</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;========================================&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOG</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#------Fin du fichier /usr/local/scripts/snapshot.sh</span></pre></td></tr></table></div>

<h3>En résumé :</h3>
<p align="justify">Juste après l&#8217;exécution du script, le répertoire <em>current</em> et le répertoire &laquo;&nbsp;daté&nbsp;&raquo; sont identiques. Comme le second est créé par &laquo;&nbsp;liens durs&nbsp;&raquo;, aucun espace disque supplémentaire n&#8217;est consommé.</p>
<p align="justify">Lors de la sauvegarde suivante, la commande<em> rsync </em>va modifier le répertoire &laquo;&nbsp;<em>current&nbsp;&raquo;</em> :</p>
<ul>
<li>
<p align="justify">En effaçant les fichiers supprimés sur le serveur depuis la dernière sauvegarde &#8211; les liens durs pour ces fichiers seront cassés,</p>
</li>
<li>
<p align="justify">En ajoutant les fichiers créés sur le serveur &#8211; pas d&#8217;action sur les liens,</p>
</li>
<li>
<p align="justify">En recopiant tout fichier modifié sur le serveur, ce qui revient à supprimer l&#8217;ancienne version et créer la nouvelle &#8211; les liens portant sur les anciens fichiers seront cassés.</p>
</li>
</ul>
<p align="justify">En résumé, cette mécanique va permettre de garder un historique des fichiers du serveur, jour après  jour, en ne consommant que l&#8217;espace utilisé par les ajouts ou modifications de fichiers.</p>
<p style="text-align: center"><img src="http://www.jopa.fr/wp-content/uploads/2008/03/capture-ssh-srv_nas.png" alt="Capture" width="525" height="240" /></p>
<p style="text-align: left" align="left">
<p style="text-align: left" align="left">La notion de lien est complètement transparente pour l&#8217;utilisateur et sous chaque répertoire, nous retrouvons l&#8217;ensemble des fichiers, tels qu&#8217;ils étaient sur le serveur à la date correspondante; d&#8217;où le nom de &laquo;&nbsp;<em>snapshot</em>&nbsp;&raquo; donné à cette technique (et à mon script !)</p>
<p style="text-align: left" align="left">Pour finir, voici le petit script en un seul morceau :</p>
<p style="text-align: left" align="left">

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p23code26'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2326"><td class="code" id="p23code26"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;">#------Début du fichier /usr/local/scripts/snapshot.sh</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># PARAMETRE</span>
<span style="color: #007800;">SERVEUR</span>=<span style="color: #ff0000;">&quot;srv_file&quot;</span>
<span style="color: #007800;">DST</span>=<span style="color: #ff0000;">&quot;/srv/sauvegardes&quot;</span>
<span style="color: #007800;">LOG</span>=<span style="color: #ff0000;">&quot;/var/log/snapshot-<span style="color: #007800;">$SERVEUR</span>.log&quot;</span>
<span style="color: #007800;">DATE</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>y<span style="color: #000000; font-weight: bold;">%</span>m<span style="color: #000000; font-weight: bold;">%</span>d-<span style="color: #000000; font-weight: bold;">%</span>H<span style="color: #000000; font-weight: bold;">%</span>M<span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># SYNCHRONISATION</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Début de la sauvegarde le <span style="color: #780078;">`date +%D`</span> à <span style="color: #780078;">`date +%H:%M`</span> &quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOG</span>
<span style="color: #000000; font-weight: bold;">for</span> REP <span style="color: #000000; font-weight: bold;">in</span> etc home root data srv var ;  <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;    *    Sauvegarde de  <span style="color: #007800;">$REP</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOG</span>
    rsync <span style="color: #660033;">-ra</span> <span style="color: #660033;">--delete</span> <span style="color: #007800;">$SERVEUR</span>:<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$REP</span> <span style="color: #007800;">$DST</span><span style="color: #000000; font-weight: bold;">/</span>current <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOG</span>
<span style="color: #000000; font-weight: bold;">done</span>;
&nbsp;
<span style="color: #666666; font-style: italic;"># SNAPSHOT</span>
<span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-al</span> <span style="color: #007800;">$DST</span><span style="color: #000000; font-weight: bold;">/</span>current <span style="color: #007800;">$DST</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$DATE</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOG</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Fin de la sauvegarde le <span style="color: #780078;">`date +%D`</span> à <span style="color: #780078;">`date +%H:%M`</span> &quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOG</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;========================================&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOG</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#------Fin du fichier /usr/local/scripts/snapshot.sh</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.jopa.fr/index.php/2008/03/18/sauvegardes-differentielles-la-puissance-de-rsync-et-des-liens-durs/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

