<?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>blog.nicolas.pawlak.fr &#187; Linux</title>
	<atom:link href="http://blog.nicolas.pawlak.fr/categories/systemes-d-exploitation/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.nicolas.pawlak.fr</link>
	<description>Tux ne sait pas voler, c&#039;est normal : ce n&#039;est pas un pingouin...</description>
	<lastBuildDate>Sun, 31 Jul 2011 14:56:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Script shell vérifiant la disponibilité d&#8217;un nom de domaine</title>
		<link>http://blog.nicolas.pawlak.fr/2011/07/11/script-shell-verifiant-la-disponibilite-dun-nom-de-domaine/</link>
		<comments>http://blog.nicolas.pawlak.fr/2011/07/11/script-shell-verifiant-la-disponibilite-dun-nom-de-domaine/#comments</comments>
		<pubDate>Mon, 11 Jul 2011 21:15:27 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[disponible]]></category>
		<category><![CDATA[domaine]]></category>
		<category><![CDATA[nom]]></category>
		<category><![CDATA[script]]></category>
		<guid isPermaLink="false">http://blog.nicolas.pawlak.fr/?p=1442</guid>
		<description><![CDATA[Un petit script pour déterminer si un nom de domaine est libre ou déjà déposé. Les serveurs whois des différents registres de premier niveau renvoyant des réponses structurées différemment, il faut déterminer pour chaque TLD la réponse-type correspondant à un nom de domaine libre et l&#8217;inclure dans le script. Voici ce que retourne une requête [...]]]></description>
			<content:encoded><![CDATA[<p>Un petit script pour déterminer si un <a href="http://fr.wikipedia.org/wiki/Nom_de_domaine" title="nom de domaine" target="_blank">nom de domaine</a> est libre ou déjà déposé. </p>
<p>Les serveurs <a href="http://fr.wikipedia.org/wiki/Whois" title="whois" target="_blank">whois</a> des différents <a href="http://fr.wikipedia.org/wiki/Registre_(Noms_de_domaine)" title="registres" target="_blank">registres de premier niveau</a> renvoyant des réponses structurées différemment, il faut déterminer pour chaque <a href="http://fr.wikipedia.org/wiki/Domaine_de_premier_niveau" title="TLD" target="_blank">TLD</a> la réponse-type correspondant à un nom de domaine libre et l&#8217;inclure dans le script. </p>
<p>Voici ce que retourne une requête whois sur &laquo;&nbsp;domainequinexistesurementpas.fr&nbsp;&raquo; :</p>
<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[root@pc-linux]# whois domainequinexistesurementpas.fr
[Requête en cours whois.nic.fr]
[whois.nic.fr]
%%
%% This is the AFNIC Whois server.
%%
%% complete date format : DD/MM/YYYY
%% short date format    : DD/MM
%% version              : FRNIC-2.5
%%
%% Rights restricted by copyright.
%% See http://www.afnic.fr/afnic/web/mentions-legales-whois_en
%%
%% Use '-h' option to obtain more information about this service.
%%
%% [XX.XX.XX.XX REQUEST] &gt;&gt; domainequinexistesurementpas.fr
%%
%% RL Net [##########] - RL IP [#########.]
%%
&nbsp;
%% No entries found in the AFNIC Database.</pre></div></div>
<p>A présent, la même requête sur &laquo;&nbsp;domainequinexistesurementpas.it&nbsp;&raquo; :</p>
<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[root@pc-linux]# whois domainequinexistesurementpas.it
[Requête en cours whois.nic.it]
[whois.nic.it]
Domain:             domainequinexistesurementpas.it
Status:             AVAILABLE</pre></div></div>
<p>Les deux réponses sont totalement différentes (&laquo;&nbsp;No entries found in the AFNIC Database&nbsp;&raquo; pour le .fr, &laquo;&nbsp;Status: AVAILABLE&nbsp;&raquo; pour le .it). Il est donc indispensable de prendre en compte, pour chaque TLD, la réponse-type correspondant à un nom de domaine libre.</p>
<p>En cas d&#8217;interrogation sur un TLD qui n&#8217;a pas été prévu dans le script, ce dernier retourne : &laquo;&nbsp;TLD NON PRIS EN COMPTE&nbsp;&raquo;.</p>
<p>Une particularité du script : placer dans une variable dans une autre variable. Cette particularité apparaît au moment de filtrer la réponse avec la réponse-type correspondant au TLD : la commande <em>grep</em> doit prendre en paramètre le contenu de la variable correspondant à la réponse-type du TLD, mais le nom de cette variable n&#8217;est pas fixe.</p>
<p><strong>Le script :</strong></p>
<div class="wp_syntax"><div class="code"><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;"># On place dans une variable le TLD du domaine interrogé.</span>
<span style="color: #666666; font-style: italic;"># Le . est remplacé par _ (cas du .co.uk notamment) pour des raisons de noms de variables.</span>
<span style="color: #007800;">tld</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-f</span> <span style="color: #000000;">2</span>- <span style="color: #660033;">-d</span> . <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;s/\./_/&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># On place pour chaque TLD la réponse-type d'un domaine libre dans une variable.</span>
<span style="color: #666666; font-style: italic;"># La variable porte le nom du TLD, avec le _ remplaçant le . si nécessaire.</span>
<span style="color: #007800;">fr</span>=<span style="color: #ff0000;">&quot;No entries found&quot;</span>
<span style="color: #007800;">be</span>=<span style="color: #ff0000;">&quot;Status:      FREE&quot;</span>
<span style="color: #007800;">ch</span>=<span style="color: #ff0000;">&quot;We do not have an entry&quot;</span>
<span style="color: #007800;">de</span>=<span style="color: #ff0000;">&quot;Status: free&quot;</span>
<span style="color: #007800;">it</span>=<span style="color: #ff0000;">&quot;Status:             AVAILABLE&quot;</span>
<span style="color: #007800;">pl</span>=<span style="color: #ff0000;">&quot;No information available&quot;</span>
<span style="color: #007800;">pt</span>=<span style="color: #ff0000;">&quot;no match&quot;</span>
<span style="color: #007800;">fi</span>=<span style="color: #ff0000;">&quot;Domain not found&quot;</span>
<span style="color: #007800;">no</span>=<span style="color: #ff0000;">&quot;No match&quot;</span>
<span style="color: #007800;">nl</span>=<span style="color: #ff0000;">&quot;is free&quot;</span>
<span style="color: #007800;">dk</span>=<span style="color: #ff0000;">&quot;No entries found&quot;</span>
<span style="color: #007800;">ru</span>=<span style="color: #ff0000;">&quot;No entries found&quot;</span>
<span style="color: #007800;">at</span>=<span style="color: #ff0000;">&quot;nothing found&quot;</span>
<span style="color: #007800;">co_uk</span>=<span style="color: #ff0000;">&quot;No match for&quot;</span>
<span style="color: #007800;">net_uk</span>=<span style="color: #ff0000;">&quot;Not match for&quot;</span>
<span style="color: #007800;">org_uk</span>=<span style="color: #ff0000;">&quot;No match for&quot;</span>
<span style="color: #007800;">uk</span>=<span style="color: #ff0000;">&quot;Error for&quot;</span>
<span style="color: #007800;">com</span>=<span style="color: #ff0000;">&quot;No match for&quot;</span>
<span style="color: #007800;">net</span>=<span style="color: #ff0000;">&quot;No match for&quot;</span>
<span style="color: #007800;">org</span>=<span style="color: #ff0000;">&quot;NOT FOUND&quot;</span>
<span style="color: #007800;">info</span>=<span style="color: #ff0000;">&quot;NOT FOUND&quot;</span>
<span style="color: #007800;">biz</span>=<span style="color: #ff0000;">&quot;Not found&quot;</span>
<span style="color: #007800;">ws</span>=<span style="color: #ff0000;">&quot;No match for&quot;</span>
<span style="color: #007800;">edu</span>=<span style="color: #ff0000;">&quot;No Match&quot;</span>
<span style="color: #007800;">xxx</span>=<span style="color: #ff0000;">&quot;No match for&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #007800;">$1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;PARAMETRE MANQUANT&quot;</span>
<span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #007800;">$2</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
                <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${!tld}</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
                        <span style="color: #666666; font-style: italic;"># Aucune variable n'est nommée comme le TLD : pas de réponse-type</span>
                        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;TLD NON PRIS EN COMPTE&quot;</span>
                <span style="color: #000000; font-weight: bold;">else</span>
                        <span style="color: #666666; font-style: italic;"># On filtre la réponse du whois avec la réponse-type du TLD.</span>
                        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #780078;">`whois $1 | grep &quot;${!tld}&quot;`</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
                                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ENREGISTRE&quot;</span>
                        <span style="color: #000000; font-weight: bold;">else</span>
                                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;LIBRE&quot;</span>
                        <span style="color: #000000; font-weight: bold;">fi</span>
                <span style="color: #000000; font-weight: bold;">fi</span>
        <span style="color: #000000; font-weight: bold;">else</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;PARAMETRE EN TROP&quot;</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>
<p>Le script en action :</p>
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>pc-linux<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># ./dispo_ndd.sh domaine.fr</span>
ENREGISTRE
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>pc-linux<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># ./dispo_ndd.sh domaine-existepas.fr</span>
LIBRE
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>pc-linux<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># ./dispo_ndd.sh domaine.ca</span>
DOMAINE NON DISPONIBLE</pre></div></div>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.nicolas.pawlak.fr/2011/07/11/script-shell-verifiant-la-disponibilite-dun-nom-de-domaine/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Script de relance automatique du serveur SSH</title>
		<link>http://blog.nicolas.pawlak.fr/2010/09/21/script-de-relance-automatique-du-serveur-ssh/</link>
		<comments>http://blog.nicolas.pawlak.fr/2010/09/21/script-de-relance-automatique-du-serveur-ssh/#comments</comments>
		<pubDate>Tue, 21 Sep 2010 18:00:53 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[dedibox]]></category>
		<category><![CDATA[dédié]]></category>
		<category><![CDATA[ovh]]></category>
		<category><![CDATA[relance]]></category>
		<category><![CDATA[restart]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[serveur]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[sshd]]></category>
		<category><![CDATA[start]]></category>
		<category><![CDATA[stop]]></category>
		<guid isPermaLink="false">http://blog.nicolas.pawlak.fr/?p=1267</guid>
		<description><![CDATA[Lorsque l&#8217;on administre un serveur à distance sans accès physique sur la machine, bien souvent, l&#8217;accès au serveur tient à un fil : celui du SSH. Si, pour une raison ou une autre, le serveur SSH s&#8217;arrête&#8230; les ennuis commencent pour l&#8217;administrateur et les utilisateurs. Même si les connexions SSH actives ne sont pas interrompues [...]]]></description>
			<content:encoded><![CDATA[<p>Lorsque l&#8217;on administre un serveur à distance sans accès physique sur la machine, bien souvent, l&#8217;accès au serveur tient à un fil : celui du <a href="http://fr.wikipedia.org/wiki/SSH">SSH</a>. Si, pour une raison ou une autre, le serveur SSH s&#8217;arrête&#8230; les ennuis commencent pour l&#8217;administrateur et les utilisateurs.</p>
<p>Même si les connexions SSH actives ne sont pas interrompues lors de l&#8217;arrêt du serveur (à condition de ne pas tout stopper avec un <a href="http://pwet.fr/man/linux/commandes/killall"><i>killall</i></a> !), il suffit d&#8217;un peu de malchance pour que celles-ci le soient : un plantage de votre système, une coupure électrique, une déconnexion de votre <a href="http://fr.wikipedia.org/wiki/Fournisseur_d%27acc%C3%A8s_%C3%A0_Internet">FAI</a> juste après l&#8217;arrêt du serveur SSH et vous voilà coincé à la porte de votre serveur distant.</p>
<p>Pour éviter cela, j&#8217;ai imaginé un script qui vérifierait régulièrement l&#8217;état du serveur SSH et le relancerait si besoin, avec restauration d&#8217;une sauvegarde du fichier <a href="http://pwet.fr/man/linux/formats/sshd_config">sshd_config</a> en cas d&#8217;échec lors du redémarrage. Ce script est évidemment à placer dans la <a href="http://fr.wikipedia.org/wiki/Crontab">crontab</a> d&#8217;un utilisateur ayant les droits requis pour travailler dans le répertoire de configuration de SSH et redémarrer le service&#8230; c&#8217;est à dire <a href="http://fr.wikipedia.org/wiki/Utilisateur_root"><i>root</i></a>, pour faire simple.</p>
<p><strong>Attention :</p>
<p>- Vérifiez bien votre configuration pour les variables déclarées en entête du fichier. Par exemple, le service se nomme &laquo;&nbsp;ssh&nbsp;&raquo; sur Debian / Ubuntu, et &laquo;&nbsp;sshd&nbsp;&raquo; sur Red Hat / Fedora.</p>
<p>- Testez le script sur un environnement de test dans un premier temps, pour éviter de faire des erreurs sur un environnement de production.</strong></p>
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #007800;">n_service</span>=<span style="color: #ff0000;">&quot;ssh&quot;</span>                      <span style="color: #666666; font-style: italic;"># Nom du service</span>
<span style="color: #007800;">f_exe</span>=<span style="color: #ff0000;">&quot;/usr/sbin/sshd&quot;</span>               <span style="color: #666666; font-style: italic;"># Exécutable du service</span>
<span style="color: #007800;">f_origine</span>=<span style="color: #ff0000;">&quot;/etc/ssh/sshd_config&quot;</span>     <span style="color: #666666; font-style: italic;"># Fichier de configuration actuelle</span>
<span style="color: #007800;">f_secours</span>=<span style="color: #ff0000;">&quot;/var/scripts/sshd_config&quot;</span> <span style="color: #666666; font-style: italic;"># Sauvegarde de la configuration</span>
<span style="color: #007800;">f_log</span>=<span style="color: #ff0000;">&quot;/var/log/restart_ssh&quot;</span>         <span style="color: #666666; font-style: italic;"># Fichier de log</span>
&nbsp;
<span style="color: #007800;">now</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$(date +%d/%m/%Y' - '%H:%M)</span>&quot;</span>    <span style="color: #666666; font-style: italic;"># Date et heure pour le log</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #c20cb9; font-weight: bold;">ps</span> ax <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #007800;">$f_exe</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #000000; font-weight: bold;">&amp;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
<span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$n_service</span> start <span style="color: #000000; font-weight: bold;">&amp;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #c20cb9; font-weight: bold;">ps</span> ax <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #007800;">$f_exe</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #000000; font-weight: bold;">&amp;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
        <span style="color: #000000; font-weight: bold;">then</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;[<span style="color: #007800;">$now</span>] <span style="color: #007800;">$n_service</span> redémarré automatiquement&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$f_log</span>
        <span style="color: #000000; font-weight: bold;">else</span>
                <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #007800;">$f_origine</span>
                <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #007800;">$f_secours</span> <span style="color: #007800;">$f_origine</span>
                <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$n_service</span> start <span style="color: #000000; font-weight: bold;">&amp;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
                <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #c20cb9; font-weight: bold;">ps</span> ax <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #007800;">$f_exe</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #000000; font-weight: bold;">&amp;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
                <span style="color: #000000; font-weight: bold;">then</span>
                        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;[<span style="color: #007800;">$now</span>] <span style="color: #007800;">$n_service</span> redémarré après restauration&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$f_log</span>
                <span style="color: #000000; font-weight: bold;">else</span>
                        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;[<span style="color: #007800;">$now</span>] <span style="color: #007800;">$n_service</span> arrêté, restauration inefficace&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$f_log</span>
                <span style="color: #000000; font-weight: bold;">fi</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>
<p>Crontab root (à adapter selon vos souhaits, ici un lancement du script toutes les minutes) :</p>
<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">#       minute (de 0 à 59)
&nbsp;
#       |       heure (de 0 à 23)
&nbsp;
#       |       |       jour (de 1 à 31)
&nbsp;
#       |       |       |       mois (de 1 à 12)
&nbsp;
#       |       |       |       |       jour de la semaine (de 0 à 6, 0 = dimanche)
&nbsp;
#       |       |       |       |       |       commande
&nbsp;
        */1     *       *       *       *       /bin/bash /var/scripts/restart_ssh.sh</pre></div></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.nicolas.pawlak.fr/2010/09/21/script-de-relance-automatique-du-serveur-ssh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LastFM : quand Decibel Audio Player ne scrobble plus correctement&#8230;</title>
		<link>http://blog.nicolas.pawlak.fr/2010/07/10/lastfm-quand-decibel-audio-player-ne-scrobble-plus-correctement/</link>
		<comments>http://blog.nicolas.pawlak.fr/2010/07/10/lastfm-quand-decibel-audio-player-ne-scrobble-plus-correctement/#comments</comments>
		<pubDate>Sat, 10 Jul 2010 15:00:43 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
				<category><![CDATA[Decibel Audio Player]]></category>
		<category><![CDATA[LastFM]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[decibel]]></category>
		<category><![CDATA[fm]]></category>
		<category><![CDATA[last]]></category>
		<category><![CDATA[lastfm]]></category>
		<category><![CDATA[player]]></category>
		<category><![CDATA[scrobbler]]></category>
		<category><![CDATA[scrobbling]]></category>
		<guid isPermaLink="false">http://blog.nicolas.pawlak.fr/?p=1068</guid>
		<description><![CDATA[Decibel Audio Player est un lecteur audio pour Linux (sous environnement GNOME), écrit en Python. Léger et simple d&#8217;utilisation, il apporte tout le nécessaire à l&#8217;écoute de fichiers musicaux sur une machine, sans le superflu. Pas mal d&#8217;options sont présentes sous forme d&#8217;options dans le menu &#171;&#160;Préférences&#160;&#187;, ce qui permet de n&#8217;activer que ce dont [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://decibel.silent-blade.org/">Decibel Audio Player</a> est un lecteur audio pour Linux (sous environnement <a href="http://doc.ubuntu-fr.org/gnome">GNOME</a>), écrit en <a href="http://fr.wikipedia.org/wiki/Python_%28langage%29">Python</a>. Léger et simple d&#8217;utilisation, il apporte tout le nécessaire à l&#8217;écoute de fichiers musicaux sur une machine, sans le superflu. Pas mal d&#8217;options sont présentes sous forme d&#8217;options dans le menu &laquo;&nbsp;Préférences&nbsp;&raquo;, ce qui permet de n&#8217;activer que ce dont vous avez réellement besoin. Après avoir essayé bon nombre de lecteurs audio (<a href="http://doc.ubuntu-fr.org/Amarok">Amarok</a>, <a href="http://doc.ubuntu-fr.org/Listen">Listen</a>, <a href="http://doc.ubuntu-fr.org/Exaile">Exaile</a>&#8230; et <a href="http://moc.daper.net/">MOC</a> !), j&#8217;ai finalement adopté Decibel depuis un ou deux ans.</p>
<p align="center"><img alt="decibel-audio-player" src="http://decibel.silent-blade.org/uploads/Main/main-library.png" title="decibel-audio-player" class="aligncenter" width="70%" height="70%" /></p>
<p><a href="http://www.lastfm.fr">LastFM</a> est une sorte de &laquo;&nbsp;réseau social musical&nbsp;&raquo; : votre lecteur audio soumet au site la liste des titres que vous écoutez, ce qui permet de constituer au fil du temps des statistiques sur vos goûts musicaux. L&#8217;intérêt ? Pouvoir vous proposer des noms d&#8217;artistes pouvant correspondre à vos goûts, des <a href="http://www.lastfm.fr/events">concerts</a> des artistes que vous écoutez régulièrement, découvrir vos affinités musicales avec d&#8217;autres utilisateurs&#8230; et pouvoir écouter légalement des extraits de beaucoup d&#8217;albums. Bref, pour ceux qui écoutent beaucoup de musique, fréquentent de temps à autres les salles de concert et recherchent des nouveautés, LastFM est le site qu&#8217;il vous faut.</p>
<p>Vous pouvez visiter mon <a href="http://www.lastfm.fr/user/HostOfSeraphim">profil LastFM</a> pour avoir un aperçu des fonctionnalités.</p>
<p align="center"><img alt="Lastfm" src="http://transientwriting.files.wordpress.com/2008/10/last-fm-logo.png" title="LastFM" class="aligncenter" width="50%" height="50%" /></p>
<p>La transmission à LastFM de vos données d&#8217;écoute porte un nom bien spécifique : le <em>scrobbling</em>. C&#8217;est cette fonctionnalité là qui pose problème à Decibel : au moins de quelques temps d&#8217;utilisation (un mois, six mois, voire plus&#8230;), l&#8217;outil de <em>scrobbling</em> ne fonctionne plus : si vous consultez votre page LastFM, vous vous apercevez que seul le titre actuellement écouté apparaît, et que plus aucun titre n&#8217;est conservé dans l&#8217;historique. Bref, à part afficher le titre en cours, votre profil LastFM ne bouge plus d&#8217;un poil.</p>
<p>Le problème est en fait lié aux <a href="http://fr.wikipedia.org/wiki/ID3"><em>ID3 tags</em></a> de certains titres, comportant des caractères non acceptés par LastFM qui refuse alors la soumission ; le titre reste donc en cache (fichier ~/.config/decibel-audio-player/audioscrobbler-cache.txt), et les titres joués à la suite y restent également bloqués.</p>
<p>Dans mon cas, voici le nom d&#8217;artiste du premier titre présent en cache :</p>
<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">a[*]=%44%65%76%69%6E%20%54%6F%77%6E%73%65%6E%64%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0</pre></div></div>
<p>Ce qui nous donne, une fois converti, le nom d&#8217;artiste suivant :</p>
<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">a[*]=Devin Townsend\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0</pre></div></div>
<p>Les caractères « \0 » empêchent la soumission du titre auprès de LastFM. Il faut donc supprimer du fichier toute ligne &laquo;&nbsp;mal formatée&nbsp;&raquo; pour que le cache puisse être soumis à nouveau et que le scrobbling retrouve son comportement normal.</p>
<p>Il est possible aussi de tout simplement supprimer le fichier de cache, si vous souhaitez faire simple :</p>
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>machine:~$ <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> ~<span style="color: #000000; font-weight: bold;">/</span>.config<span style="color: #000000; font-weight: bold;">/</span>decibel-audio-player<span style="color: #000000; font-weight: bold;">/</span>audioscrobbler-cache.txt</pre></div></div>
<p>Le <em>bug</em> a été signalé au développeur de Decibel, qui a réglé le problème dans la version &laquo;&nbsp;trunk&nbsp;&raquo;. Il devrait donc être corrigé dans la version 1.06 du logiciel.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nicolas.pawlak.fr/2010/07/10/lastfm-quand-decibel-audio-player-ne-scrobble-plus-correctement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Retirer les lignes vides d&#8217;un fichier sous Linux</title>
		<link>http://blog.nicolas.pawlak.fr/2010/06/13/retirer-les-lignes-vides-dun-fichier-sous-linux/</link>
		<comments>http://blog.nicolas.pawlak.fr/2010/06/13/retirer-les-lignes-vides-dun-fichier-sous-linux/#comments</comments>
		<pubDate>Sun, 13 Jun 2010 08:00:52 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[awk]]></category>
		<category><![CDATA[cat]]></category>
		<category><![CDATA[empty]]></category>
		<category><![CDATA[enlever]]></category>
		<category><![CDATA[fichier]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[ligne]]></category>
		<category><![CDATA[lignes]]></category>
		<category><![CDATA[line]]></category>
		<category><![CDATA[retirer]]></category>
		<category><![CDATA[sed]]></category>
		<category><![CDATA[vide]]></category>
		<category><![CDATA[vides]]></category>
		<guid isPermaLink="false">http://blog.nicolas.pawlak.fr/?p=981</guid>
		<description><![CDATA[Ces petites commandes méritent à être retenues, pour gagner du temps le jour où on est confronté au problème&#8230; et que l&#8217;on a pas Google sous la main ! Prenons un fichier test.txt qui nous servira d&#8217;exemple : &#91;root@pc-linux&#93;# cat test.txt test 1 &#160; test 2 test 3 &#160; test 4 test 5 test 6 [...]]]></description>
			<content:encoded><![CDATA[<p>Ces petites commandes méritent à être retenues, pour gagner du temps le jour où on est confronté au problème&#8230; et que l&#8217;on a pas <a href="http://www.google.fr/">Google</a> sous la main !</p>
<p>Prenons un fichier test.txt qui nous servira d&#8217;exemple :</p>
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>pc-linux<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># cat test.txt</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">1</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">2</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">3</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">4</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">5</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">6</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">7</span></pre></div></div>
<p><strong>Avec <a href="http://fr.wikipedia.org/wiki/Stream_Editor">sed</a> :</strong></p>
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>pc-linux<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># sed '/^$/D' test.txt</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">2</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">3</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">4</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">5</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">6</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">7</span></pre></div></div>
<p><strong>Avec <a href="http://fr.wikipedia.org/wiki/Awk">awk</a> :</strong></p>
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>pc-linux<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># awk NF test.txt</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">2</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">3</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">4</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">5</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">6</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">7</span></pre></div></div>
<p>Variante :</p>
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>pc-linux<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># awk '/./' test.txt</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">2</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">3</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">4</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">5</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">6</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">7</span></pre></div></div>
<p><strong>Sans awk ni sed :</strong></p>
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>pc-linux<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># cat test.txt | grep '.'</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">2</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">3</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">4</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">5</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">6</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">7</span></pre></div></div>
<p>Variante :</p>
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>pc-linux<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># cat test.txt | grep -v '^$'</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">2</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">3</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">4</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">5</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">6</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000;">7</span></pre></div></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.nicolas.pawlak.fr/2010/06/13/retirer-les-lignes-vides-dun-fichier-sous-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cacher un utilisateur dans la fenêtre de connexion GNOME</title>
		<link>http://blog.nicolas.pawlak.fr/2010/06/01/cacher-un-utilisateur-dans-la-fenetre-de-connexion-gnome/</link>
		<comments>http://blog.nicolas.pawlak.fr/2010/06/01/cacher-un-utilisateur-dans-la-fenetre-de-connexion-gnome/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 08:30:17 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[cacher]]></category>
		<category><![CDATA[connexion]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[exclude]]></category>
		<category><![CDATA[gdm]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[greeter]]></category>
		<category><![CDATA[schemas]]></category>
		<category><![CDATA[uid]]></category>
		<category><![CDATA[utilisateur]]></category>
		<guid isPermaLink="false">http://blog.nicolas.pawlak.fr/?p=943</guid>
		<description><![CDATA[Aussi curieux que cela puisse paraître, il n&#8217;y a pas de solution graphique utilisable pour cacher un utilisateur dans la fenêtre de connexion GNOME. Imaginons que nous voulions cacher le compte &#171;&#160;toto&#160;&#187;. Dans le fichier /etc/gdm/gdm.schemas, repérez les lignes suivantes : &#60;schema&#62; &#60;key&#62;greeter/Exclude&#60;/key&#62; &#60;signature&#62;s&#60;/signature&#62; &#60;default&#62;bin,root,daemon,adm,lp,sync,shutdown,halt,mail,news,uucp&#60;/default&#62; &#60;/schema&#62; Ajoutez &#171;&#160;toto&#160;&#187; à la liste existante : &#60;schema&#62; &#60;key&#62;greeter/Exclude&#60;/key&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Aussi curieux que cela puisse paraître, il n&#8217;y a pas de solution graphique utilisable pour cacher un utilisateur dans la fenêtre de connexion <a href="http://fr.wikipedia.org/wiki/GNOME">GNOME</a>.</p>
<p>Imaginons que nous voulions cacher le compte &laquo;&nbsp;toto&nbsp;&raquo;. Dans le fichier <strong>/etc/gdm/gdm.schemas</strong>, repérez les lignes suivantes :</p>
<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">&lt;schema&gt;
  &lt;key&gt;greeter/Exclude&lt;/key&gt;
  &lt;signature&gt;s&lt;/signature&gt;
  &lt;default&gt;bin,root,daemon,adm,lp,sync,shutdown,halt,mail,news,uucp&lt;/default&gt;
&lt;/schema&gt;</pre></div></div>
<p>Ajoutez &laquo;&nbsp;toto&nbsp;&raquo; à la liste existante :</p>
<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">&lt;schema&gt;
  &lt;key&gt;greeter/Exclude&lt;/key&gt;
  &lt;signature&gt;s&lt;/signature&gt;
  &lt;default&gt;toto,bin,root,daemon,adm,lp,sync,shutdown,halt,mail,news,uucp&lt;/default&gt;
&lt;/schema&gt;</pre></div></div>
<p>Au redémarrage de GDM, toto n&#8217;apparaîtra plus dans la liste des utilisateurs.</p>
<p><em>Pour des raisons de lisibilité, la liste des utilisateurs entre les balises a été tronquée.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nicolas.pawlak.fr/2010/06/01/cacher-un-utilisateur-dans-la-fenetre-de-connexion-gnome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

