<?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>ldlabs.org - Blog &#187; bash</title>
	<atom:link href="http://www.ldlabs.org/blog/tag/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ldlabs.org/blog</link>
	<description>Linux Tips &#38; c.</description>
	<lastBuildDate>Tue, 24 Jan 2012 08:09:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>eeepc 901go key to enable/disable wireless</title>
		<link>http://www.ldlabs.org/blog/2009/05/26/eeepc-901go-key-to-enabledisable-wireless/</link>
		<comments>http://www.ldlabs.org/blog/2009/05/26/eeepc-901go-key-to-enabledisable-wireless/#comments</comments>
		<pubDate>Tue, 26 May 2009 12:24:46 +0000</pubDate>
		<dc:creator>Francesco Apollonio</dc:creator>
				<category><![CDATA[Guide]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[eeepc]]></category>
		<category><![CDATA[kde]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[utility]]></category>
		<category><![CDATA[wireless]]></category>

		<guid isPermaLink="false">http://blog.ldlabs.org/?p=524</guid>
		<description><![CDATA[Come far funzionare la combinazione Fn+F2 di un Eeepc 901Go per attivare/disattivare la scheda wireless.]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
#F0F4F9 
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:110px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:110px;
margin:4px 4px 4px 4px;
}

</style>
<p>Anche in vacanza mi fanno lavorare!</p>
<p>&#8220;Tutta colpa&#8221; di mio fratello che ha comprato un <strong>Eeepc 901Go</strong> e dopo averci messo <em>kubuntu</em>/<em>ubuntu</em> ha notato il non funzionamento della shortcut <strong>Fn+F2</strong> che permette lo spegnimento/accensione della scheda wireless e dell&#8217;annesso led in basso.</p>
<p>Son fin da subito riuscito a disattivare il led e la scheda ma il problema era la riaccensione infatti non funzionava se non riavviando il sistema&#8230; poi ieri sera finalmente ecco la soluzione!</p>
<p>Bisogna modificare il file <em>/boot/grub/menu.lst</em> per impostare alcuni parametri al caricamento del kernel (infatti il modulo incriminato di questo &#8220;malfunzionamento&#8221; è <em>pciehp</em> che è compilato staticamente), queste sono le modifiche da effettuare; si devono aggiungere alla linea <em>kernel </em>del file le stringhe<em> &#8220;pciehp.pciehp_force=1 pciehp.pciehp_poll_mode=1</em>&#8221; in modo da avere alla fine questo risultato:</p>
<pre>kernel		/boot/vmlinuz-2.6.28-11-generic root=UUID=3ddd8611-ec14-4c47-8812-d76a58ffe048 ro quiet splash pciehp.pciehp_force=1 pciehp.pciehp_poll_mode=1</pre>
<p>Dopo aver riavviato il sistema passiamo a testare il corretto funzionamento di tutto, prima di tutto disattiviamo la scheda:</p>
<pre>ifdown wlan0
ifconfig wlan0 down
echo 0 > /sys/class/rfkill/rfkill0/state
modprobe -r ath5k</pre>
<p>Ora proviamo a riattivarla:</p>
<pre>echo 1 > /sys/class/rfkill/rfkill0/state
modprobe ath5k
ifconfig wlan0 up
ifup wlan0</pre>
<p>A questo punto connettiamoci come solitamente facciamo (dall&#8217;applet nella <em>systray </em>da <em>pppoeconf </em>o da qualsiasi altro programma), la scheda è nuovamente attiva!</p>
<p>Ora scriviamo un piccolo script da associare alla combinazione di tasti <strong>Fn+F2</strong>:</p>

<div class="wp_codebox"><table><tr id="p5241"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code" id="p524code1"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #007800;">TMP</span>=<span style="color: #ff0000;">'/tmp/wireswitch'</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$TMP</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #007800;">$TMP</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>sys<span style="color: #000000; font-weight: bold;">/</span>class<span style="color: #000000; font-weight: bold;">/</span>rfkill<span style="color: #000000; font-weight: bold;">/</span>rfkill0<span style="color: #000000; font-weight: bold;">/</span>state
        modprobe ath5k
        <span style="color: #c20cb9; font-weight: bold;">ifconfig</span> wlan0 up
        <span style="color: #c20cb9; font-weight: bold;">ifup</span> wlan0
<span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #007800;">$TMP</span>
        <span style="color: #c20cb9; font-weight: bold;">ifdown</span> wlan0
        <span style="color: #c20cb9; font-weight: bold;">ifconfig</span> wlan0 down
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000;">0</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>sys<span style="color: #000000; font-weight: bold;">/</span>class<span style="color: #000000; font-weight: bold;">/</span>rfkill<span style="color: #000000; font-weight: bold;">/</span>rfkill0<span style="color: #000000; font-weight: bold;">/</span>state
        modprobe <span style="color: #660033;">-r</span> ath5k
<span style="color: #000000; font-weight: bold;">fi</span></pre></td></tr></table></div>

<p>Ora non vi resta che copiare lo script in <em>/usr/sbin</em> e associarlo al vostro gestore delle <em>shortcut</em>.</p>
<p>Ricordatevi solo che tutti i comandi vanno eseguiti come root quindi, in fase di associazione del comando alla combinazione, ricordatevi di premettere <strong>kdesudo</strong> o <strong>gtksudo</strong> al nome dello script.</p>
<div id="bottomcontainerBox">
			<div class="buttons">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.ldlabs.org%2Fblog%2F2009%2F05%2F26%2Feeepc-901go-key-to-enabledisable-wireless%2F&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe></div>
			<div class="buttons">
			<g:plusone size="medium" href="http://www.ldlabs.org/blog/2009/05/26/eeepc-901go-key-to-enabledisable-wireless/"></g:plusone>
			</div>
			<div class="buttons">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.ldlabs.org/blog/2009/05/26/eeepc-901go-key-to-enabledisable-wireless/"  data-text="eeepc 901go key to enable/disable wireless" data-count="horizontal">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://www.ldlabs.org/blog/2009/05/26/eeepc-901go-key-to-enabledisable-wireless/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>date and time in bash history</title>
		<link>http://www.ldlabs.org/blog/2009/05/10/date-and-time-in-bash-history/</link>
		<comments>http://www.ldlabs.org/blog/2009/05/10/date-and-time-in-bash-history/#comments</comments>
		<pubDate>Sun, 10 May 2009 09:21:25 +0000</pubDate>
		<dc:creator>Francesco Apollonio</dc:creator>
				<category><![CDATA[Guide]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[utility]]></category>

		<guid isPermaLink="false">http://www.ldlabs.org/blog/?p=468</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
#F0F4F9 
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:110px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:110px;
margin:4px 4px 4px 4px;
}

</style>
Riprendendo questo articolo segnalo una comoda configurazione di bash history per inserire l&#8217;orario e la data di esecuzione di un comando. Basta inserire in .bashrc questa riga: 1 export HISTTIMEFORMAT=&#34;%h/%d - %H:%M:%S &#34; al prossimo login il formato del vostro file .bash_history cambierà. Tweet]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
#F0F4F9 
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:110px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:110px;
margin:4px 4px 4px 4px;
}

</style>
<p>Riprendendo <a href="http://www.debianadmin.com/how-to-add-date-and-time-to-your-bash-history-file.html" target="_blank">questo articolo</a> segnalo una comoda configurazione di <strong>bash history</strong> per inserire l&#8217;orario e la data di esecuzione di un comando.</p>
<p>Basta inserire in .<em>bashrc</em> questa riga:</p>

<div class="wp_codebox"><table><tr id="p4683"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p468code3"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">HISTTIMEFORMAT</span>=<span style="color: #ff0000;">&quot;%h/%d - %H:%M:%S &quot;</span></pre></td></tr></table></div>

<p>al prossimo login il formato del vostro file <em>.bash_history</em> cambierà.</p>
<div id="bottomcontainerBox">
			<div class="buttons">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.ldlabs.org%2Fblog%2F2009%2F05%2F10%2Fdate-and-time-in-bash-history%2F&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe></div>
			<div class="buttons">
			<g:plusone size="medium" href="http://www.ldlabs.org/blog/2009/05/10/date-and-time-in-bash-history/"></g:plusone>
			</div>
			<div class="buttons">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.ldlabs.org/blog/2009/05/10/date-and-time-in-bash-history/"  data-text="date and time in bash history" data-count="horizontal">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://www.ldlabs.org/blog/2009/05/10/date-and-time-in-bash-history/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>kernel parameters in bash scripts</title>
		<link>http://www.ldlabs.org/blog/2009/05/09/kernel-parameters-in-bash-scripts/</link>
		<comments>http://www.ldlabs.org/blog/2009/05/09/kernel-parameters-in-bash-scripts/#comments</comments>
		<pubDate>Sat, 09 May 2009 12:09:14 +0000</pubDate>
		<dc:creator>Francesco Apollonio</dc:creator>
				<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[code tips]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[Guide]]></category>
		<category><![CDATA[utility]]></category>
		<category><![CDATA[varie]]></category>
		<category><![CDATA[X]]></category>

		<guid isPermaLink="false">http://www.ldlabs.org/blog/?p=460</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
#F0F4F9 
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:110px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:110px;
margin:4px 4px 4px 4px;
}

</style>
Vi è mai capitato di dover differenziare il comportamento di uno script sin dall&#8217;avvio del  vostro computer? Ad esempio mi occorreva disabilitare l&#8217;avvio automatico di X subito dopo il login da tty (vedere xttydm), ecco come farlo passando un semplice parametro al kernel in fase di caricamento. Il funzionamento è molto semplice: tutti i parametri [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
#F0F4F9 
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:110px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:110px;
margin:4px 4px 4px 4px;
}

</style>
<p>Vi è mai capitato di dover differenziare il comportamento di uno script sin dall&#8217;avvio del  vostro computer?</p>
<p>Ad esempio mi occorreva disabilitare l&#8217;avvio automatico di X subito dopo il login da <em>tty</em> (vedere <a href="http://www.ldlabs.org/blog/2009/02/05/xttydm/" target="_blank">xttydm</a>), ecco come farlo passando un semplice parametro al kernel in fase di caricamento.</p>
<p>Il funzionamento è molto semplice: tutti i parametri di avvio del kernel possono essere trovati in <em>/proc/cmdline</em>, basta semplicemente controllare che il parametro che ci interessa esista:</p>

<div class="wp_codebox"><table><tr id="p4605"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p460code5"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">case</span> <span style="color: #007800;">$TERM</span> <span style="color: #000000; font-weight: bold;">in</span>
linux<span style="color: #7a0874; font-weight: bold;">&#41;</span> 
<span style="color: #007800;">START</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span>cmdline <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> xtty<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #007800;">$START</span> <span style="color: #7a0874; font-weight: bold;">&#93;</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;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>startx.sh <span style="color: #000000; font-weight: bold;">&amp;&amp;</span>
<span style="color: #000000; font-weight: bold;">fi</span> <span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">esac</span></pre></td></tr></table></div>

<p>inserite questo codice in .<em>bashrc</em> e ad ogni login da <em>tty</em> se l&#8217;opzione <strong>xtty</strong> è presente come parametro del kernel, <em>X</em> verrà automaticamente fatto partire.</p>
<p>Semplice no? <img src='http://www.ldlabs.org/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley colorbox-460' /> </p>
<div id="bottomcontainerBox">
			<div class="buttons">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.ldlabs.org%2Fblog%2F2009%2F05%2F09%2Fkernel-parameters-in-bash-scripts%2F&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe></div>
			<div class="buttons">
			<g:plusone size="medium" href="http://www.ldlabs.org/blog/2009/05/09/kernel-parameters-in-bash-scripts/"></g:plusone>
			</div>
			<div class="buttons">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.ldlabs.org/blog/2009/05/09/kernel-parameters-in-bash-scripts/"  data-text="kernel parameters in bash scripts" data-count="horizontal">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://www.ldlabs.org/blog/2009/05/09/kernel-parameters-in-bash-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>proxytunnel, come connettersi ad un server ssh tramite un web proxy</title>
		<link>http://www.ldlabs.org/blog/2009/03/16/proxytunnel-come-connettersi-ad-un-server-ssh-tramite-un-web-proxy/</link>
		<comments>http://www.ldlabs.org/blog/2009/03/16/proxytunnel-come-connettersi-ad-un-server-ssh-tramite-un-web-proxy/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 15:43:59 +0000</pubDate>
		<dc:creator>Francesco Apollonio</dc:creator>
				<category><![CDATA[Guide]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[utility]]></category>
		<category><![CDATA[varie]]></category>

		<guid isPermaLink="false">http://www.ldlabs.org/blog/?p=115</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
#F0F4F9 
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:110px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:110px;
margin:4px 4px 4px 4px;
}

</style>
Ho sempre avuto problemi a connettermi al mio pc tramite ssh quando sono in facoltà per colpa del proxy web, poi fu la luce&#8230; Per prima cosa impostate il vostro server ssh sulla porta 443 (https) per bypassare eventuali controlli sulla porta. Scaricate ProxyTunnel e successivamente passate a modificare (o creare) il vostro file .ssh/config [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
#F0F4F9 
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:110px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:110px;
margin:4px 4px 4px 4px;
}

</style>
<p>Ho sempre avuto problemi a connettermi al mio pc tramite <em>ssh</em> quando sono in facoltà per colpa del proxy web, poi fu la luce&#8230;</p>
<p>Per prima cosa impostate il vostro server ssh sulla porta <strong>443</strong> <em>(https)</em> per bypassare eventuali controlli sulla porta.</p>
<p>Scaricate <a href="http://proxytunnel.sourceforge.net/download.php" target="_blank">ProxyTunnel</a> e successivamente passate a modificare (o creare) il vostro file<em> .ssh/config</em> in questo modo:</p>
<pre>Host *.miodominio.org
DynamicForward 1080
ProxyCommand PATH_ESEGUIBILE_PROXYTUNNEL/proxytunnel -v -p INDIRIZZO_PROXY:PORTA_PROXY -d %h:%p -H "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Win32)\n"
ServerAliveInterval 30</pre>
<p>ora non vi resta che connettervi normalmente al vostro pc tramite il solito comando:</p>
<pre>$ ssh -p 443 pc.miodominio.org</pre>
<p>Ecco tutto <img src='http://www.ldlabs.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley colorbox-115' /> </p>
<div id="bottomcontainerBox">
			<div class="buttons">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.ldlabs.org%2Fblog%2F2009%2F03%2F16%2Fproxytunnel-come-connettersi-ad-un-server-ssh-tramite-un-web-proxy%2F&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe></div>
			<div class="buttons">
			<g:plusone size="medium" href="http://www.ldlabs.org/blog/2009/03/16/proxytunnel-come-connettersi-ad-un-server-ssh-tramite-un-web-proxy/"></g:plusone>
			</div>
			<div class="buttons">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.ldlabs.org/blog/2009/03/16/proxytunnel-come-connettersi-ad-un-server-ssh-tramite-un-web-proxy/"  data-text="proxytunnel, come connettersi ad un server ssh tramite un web proxy" data-count="horizontal">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://www.ldlabs.org/blog/2009/03/16/proxytunnel-come-connettersi-ad-un-server-ssh-tramite-un-web-proxy/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>mpcplay, semplice aprire un file musicale con mpd</title>
		<link>http://www.ldlabs.org/blog/2009/03/06/mpcplay-semplice-aprire-un-file-musicale-con-mpd/</link>
		<comments>http://www.ldlabs.org/blog/2009/03/06/mpcplay-semplice-aprire-un-file-musicale-con-mpd/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 09:35:06 +0000</pubDate>
		<dc:creator>Francesco Apollonio</dc:creator>
				<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mpd]]></category>
		<category><![CDATA[program]]></category>
		<category><![CDATA[utility]]></category>
		<category><![CDATA[varie]]></category>

		<guid isPermaLink="false">http://www.ldlabs.org/blog/?p=81</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
#F0F4F9 
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:110px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:110px;
margin:4px 4px 4px 4px;
}

</style>
Avevo la necessità di trovare un modo rapido per aprire files e cartelle direttamente facendoci click dal files-manager, ed ecco che è nato questo semplice script (che utilizza mpc). 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
#F0F4F9 
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:110px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:110px;
margin:4px 4px 4px 4px;
}

</style>
<p>Avevo la necessità di trovare un modo rapido per aprire files e cartelle direttamente facendoci click dal files-manager, ed ecco che è nato questo semplice script (che utilizza mpc).</p>

<div class="wp_codebox"><table><tr id="p817"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
</pre></td><td class="code" id="p81code7"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash                                                                                                                                                                         </span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> usage <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Errore nei parametri&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: mpcplay [PARAMETERS] fileName&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;-ao --add-only: Aggiunge solo alla playlist&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;-p --play: Avvia anche la riproduzione (Default)&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">exit</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>                                                                
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> splitName <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$musicRootDirectory</span>&quot;</span> <span style="color: #ff0000;">'{print $2}'</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$#</span> <span style="color: #660033;">-lt</span> <span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #007800;">$#</span> <span style="color: #660033;">-gt</span> <span style="color: #000000;">2</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        usage
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #007800;">action</span>=<span style="color: #ff0000;">&quot;-p&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$#</span> <span style="color: #660033;">-eq</span> <span style="color: #000000;">2</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #007800;">action</span>=<span style="color: #ff0000;">&quot;$1&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">shift</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #007800;">lastParameter</span>=<span style="color: #ff0000;">&quot;$@&quot;</span>
<span style="color: #007800;">musicRootDirectory</span>=<span style="color: #ff0000;">&quot;Music/&quot;</span>
&nbsp;
<span style="color: #007800;">fileName</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$lastParameter</span>&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$lastParameter</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">egrep</span> <span style="color: #ff0000;">'^/'</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #007800;">fileName</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`pwd`</span>/<span style="color: #007800;">$lastParameter</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #007800;">trackName</span>=<span style="color: #000000; font-weight: bold;">`</span>splitName <span style="color: #ff0000;">&quot;<span style="color: #007800;">$fileName</span>&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
mpc <span style="color: #c20cb9; font-weight: bold;">clear</span> <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
mpc add <span style="color: #ff0000;">&quot;<span style="color: #007800;">$trackName</span>&quot;</span> <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
&nbsp;
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$action</span>&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
        <span style="color: #ff0000;">'-ao'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Added <span style="color: #007800;">$trackName</span>&quot;</span> <span style="color: #000000; font-weight: bold;">;;</span>
        <span style="color: #ff0000;">'--add-only'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Added <span style="color: #007800;">$trackName</span>&quot;</span> <span style="color: #000000; font-weight: bold;">;;</span>
        <span style="color: #ff0000;">'-p'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> mpc play <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
            <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Playing <span style="color: #007800;">$trackName</span>&quot;</span> <span style="color: #000000; font-weight: bold;">;;</span>
        <span style="color: #ff0000;">'--play'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> mpc play <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
            <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Playing <span style="color: #007800;">$trackName</span>&quot;</span> <span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">esac</span></pre></td></tr></table></div>

<p>La configurazione è semplice, basta sostituire il parametro <em>musicRootDirectory </em>con la directory relativa impostata come <em>music_</em><em>directory</em> in mpd. Ad esempio nel mio <em>mpd.conf</em>:</p>
<pre>music_directory    "/home/kekko/Music"</pre>
<p>e la variabile <em>musicRootDirectory</em> è:</p>
<pre>musicRootDirectory="Music/"</pre>
<p>Semplice vero?</p>
<div id="bottomcontainerBox">
			<div class="buttons">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.ldlabs.org%2Fblog%2F2009%2F03%2F06%2Fmpcplay-semplice-aprire-un-file-musicale-con-mpd%2F&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe></div>
			<div class="buttons">
			<g:plusone size="medium" href="http://www.ldlabs.org/blog/2009/03/06/mpcplay-semplice-aprire-un-file-musicale-con-mpd/"></g:plusone>
			</div>
			<div class="buttons">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.ldlabs.org/blog/2009/03/06/mpcplay-semplice-aprire-un-file-musicale-con-mpd/"  data-text="mpcplay, semplice aprire un file musicale con mpd" data-count="horizontal">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://www.ldlabs.org/blog/2009/03/06/mpcplay-semplice-aprire-un-file-musicale-con-mpd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>rpf &#8211; reactivate a program forever</title>
		<link>http://www.ldlabs.org/blog/2009/02/08/rpf-reactivate-a-program-forever/</link>
		<comments>http://www.ldlabs.org/blog/2009/02/08/rpf-reactivate-a-program-forever/#comments</comments>
		<pubDate>Sun, 08 Feb 2009 09:55:20 +0000</pubDate>
		<dc:creator>Francesco Apollonio</dc:creator>
				<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[utility]]></category>

		<guid isPermaLink="false">http://www.ldlabs.org/blog/?p=18</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
#F0F4F9 
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:110px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:110px;
margin:4px 4px 4px 4px;
}

</style>
avete bisogno che un vostro programma resti sempre attivo ma continua a chiudersi  inspiegabilmente e ogni volta dovete riattivarlo a mano? Questo potrebbe servirvi: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 #!/bin/bash &#160; PROGRAM=&#34;opera&#34; TIMER=&#34;5s&#34; &#160; function activate &#123; [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
#F0F4F9 
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:110px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:110px;
margin:4px 4px 4px 4px;
}

</style>
<p>avete bisogno che un vostro programma resti sempre attivo ma continua a chiudersi  inspiegabilmente e ogni volta dovete riattivarlo a mano?<br />
Questo potrebbe servirvi:</p>

<div class="wp_codebox"><table><tr id="p189"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code" id="p18code9"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #007800;">PROGRAM</span>=<span style="color: #ff0000;">&quot;opera&quot;</span>
<span style="color: #007800;">TIMER</span>=<span style="color: #ff0000;">&quot;5s&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> activate <span style="color: #7a0874; font-weight: bold;">&#123;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Attivo...&quot;</span>
<span style="color: #007800;">$PROGRAM</span> <span style="color: #000000; font-weight: bold;">&amp;</span>amp;
<span style="color: #007800;">PID</span>=<span style="color: #007800;">$!</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$PID</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">true</span>; <span style="color: #000000; font-weight: bold;">do</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #007800;">$PID</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
<span style="color: #007800;">PID</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ps</span> aux <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #007800;">$PROGRAM</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">head</span> <span style="color: #660033;">-1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $2}'</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ps</span> hp <span style="color: #007800;">$PID</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
activate
<span style="color: #000000; font-weight: bold;">else</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Gia attivo: <span style="color: #007800;">$PID</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #007800;">$TIMER</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></td></tr></table></div>

<p>una volta configurato impostando le due variabili in alto il resto è presto fatto, basta lanciarlo all&#8217;avvio!</p>
<p>Buon lavoro <img src='http://www.ldlabs.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley colorbox-18' /> </p>
<div id="bottomcontainerBox">
			<div class="buttons">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.ldlabs.org%2Fblog%2F2009%2F02%2F08%2Frpf-reactivate-a-program-forever%2F&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe></div>
			<div class="buttons">
			<g:plusone size="medium" href="http://www.ldlabs.org/blog/2009/02/08/rpf-reactivate-a-program-forever/"></g:plusone>
			</div>
			<div class="buttons">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.ldlabs.org/blog/2009/02/08/rpf-reactivate-a-program-forever/"  data-text="rpf &#8211; reactivate a program forever" data-count="horizontal">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://www.ldlabs.org/blog/2009/02/08/rpf-reactivate-a-program-forever/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ivman utility</title>
		<link>http://www.ldlabs.org/blog/2009/02/05/ivman-utility/</link>
		<comments>http://www.ldlabs.org/blog/2009/02/05/ivman-utility/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 21:13:03 +0000</pubDate>
		<dc:creator>Francesco Apollonio</dc:creator>
				<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[ivman]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pmount]]></category>
		<category><![CDATA[utility]]></category>
		<category><![CDATA[varie]]></category>

		<guid isPermaLink="false">http://www.ldlabs.org/blog/?p=14</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
#F0F4F9 
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:110px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:110px;
margin:4px 4px 4px 4px;
}

</style>
tramite pmount (ed ivman) uso montare il device con etichetta &#8220;etichetta&#8221; in una directory &#8220;/media/etichetta&#8221; (ad esempio), il piccolo inconveniente di questo metodo è che se per un qualsiasi motivo il device viene smontato in maniera &#8216;brutale&#8217; rimane in &#8220;/media/etichetta&#8221; un file di lock che mi impedisce di rimontarci dentro la mia povera pennina. bene, [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
#F0F4F9 
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:110px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:110px;
margin:4px 4px 4px 4px;
}

</style>
<p>tramite pmount (ed ivman) uso montare il device con etichetta <em>&#8220;etichetta&#8221;</em> in una directory <em>&#8220;/media/etichetta&#8221;</em> (ad esempio), il piccolo inconveniente di questo metodo è che se per un qualsiasi motivo il device viene smontato in maniera &#8216;brutale&#8217; rimane in &#8220;/media/etichetta&#8221; un file di lock che mi impedisce di rimontarci dentro la mia povera pennina.<br />
bene, questo script è la soluzione <img src='http://www.ldlabs.org/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley colorbox-14' /><br />
non fa altro che controllare se effettivamente il device è montato (in /etc/mtab) e assegna a seconda dei casi una directory su cui montare:</p>

<div class="wp_codebox"><table><tr id="p1411"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
</pre></td><td class="code" id="p14code11"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> checkIfAlreadyMounted
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
&nbsp;
<span style="color: #007800;">mountPointUsed</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>mtab <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #007800;">$2</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #007800;">dir</span>=<span style="color: #007800;">$2</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-d</span> <span style="color: #007800;">$2</span> <span style="color: #7a0874; font-weight: bold;">&#93;</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: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$mountPointUsed</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
<span style="color: #007800;">dir</span>=<span style="color: #ff0000;">&quot;$2-<span style="color: #780078;">`date +%H%m%S`</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$dir</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> checkArguments
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$#</span> <span style="color: #660033;">-ne</span> <span style="color: #000000;">2</span> <span style="color: #7a0874; font-weight: bold;">&#93;</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;Numero parametri scorretto!&quot;</span>
<span style="color: #7a0874; font-weight: bold;">exit</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-b</span> <span style="color: #007800;">$1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</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;Errore nei parametri passati!&quot;</span>
<span style="color: #7a0874; font-weight: bold;">exit</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #007800;">test</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$2</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">egrep</span> <span style="color: #ff0000;">'/$'</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$test</span> <span style="color: #660033;">-ne</span> <span style="color: #ff0000;">''</span> <span style="color: #7a0874; font-weight: bold;">&#93;</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;Errore nei parametri, il secondo paramentro non deve finire per /&quot;</span>
<span style="color: #7a0874; font-weight: bold;">exit</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #007800;">alreadyMountedDevice</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>mtab <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #007800;">$1</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$alreadyMountedDevice</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</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;Device already Mounted!&quot;</span>
<span style="color: #7a0874; font-weight: bold;">exit</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #007800;">dest</span>=<span style="color: #ff0000;">&quot;$2&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#if [[ $dest -eq &quot;/media/&quot; ]]; then</span>
<span style="color: #666666; font-style: italic;">#    dest=&quot;/media/usbdisk&quot;</span>
<span style="color: #666666; font-style: italic;">#fi</span>
&nbsp;
checkArguments <span style="color: #007800;">$1</span> <span style="color: #007800;">$dest</span>
&nbsp;
<span style="color: #007800;">dir</span>=<span style="color: #000000; font-weight: bold;">`</span>checkIfAlreadyMounted <span style="color: #007800;">$1</span> <span style="color: #007800;">$2</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;mounting $1 in <span style="color: #007800;">$dir</span>&quot;</span>
pmount <span style="color: #007800;">$1</span> <span style="color: #007800;">$dir</span>
<span style="color: #666666; font-style: italic;">#Avvia il mio files-manager</span>
pcmanfm <span style="color: #007800;">$dir</span></pre></td></tr></table></div>

<p>spero vi sia utile con il vostro ivman ed ovviamente pmount.</p>
<div id="bottomcontainerBox">
			<div class="buttons">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.ldlabs.org%2Fblog%2F2009%2F02%2F05%2Fivman-utility%2F&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe></div>
			<div class="buttons">
			<g:plusone size="medium" href="http://www.ldlabs.org/blog/2009/02/05/ivman-utility/"></g:plusone>
			</div>
			<div class="buttons">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.ldlabs.org/blog/2009/02/05/ivman-utility/"  data-text="ivman utility" data-count="horizontal">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://www.ldlabs.org/blog/2009/02/05/ivman-utility/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>xttydm (aka lanciare X dopo il login da tty)</title>
		<link>http://www.ldlabs.org/blog/2009/02/05/xttydm/</link>
		<comments>http://www.ldlabs.org/blog/2009/02/05/xttydm/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 11:41:39 +0000</pubDate>
		<dc:creator>Francesco Apollonio</dc:creator>
				<category><![CDATA[Guide]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[varie]]></category>
		<category><![CDATA[X]]></category>

		<guid isPermaLink="false">http://www.ldlabs.org/blog/?p=8</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
#F0F4F9 
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:110px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:110px;
margin:4px 4px 4px 4px;
}

</style>
non so voi ma io nutro una particolare avversione verso tutti quei login manager (gdm, kdm, xdm) che reputo pesanti e poco funzionali, soprattutto perché utilizzando un laptop ritenevo un inutile spreco di risorse (leggasi batteria) avviare tutto l&#8217;ambaradan per (ad esempio) modificare qualche piccolo file o effettuare qualche piccola operazione. E poi voglio far [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
#F0F4F9 
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:110px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:110px;
margin:4px 4px 4px 4px;
}

</style>
<p>non so voi ma io nutro una particolare avversione verso tutti quei login manager (gdm, kdm, xdm) che reputo pesanti e poco funzionali, soprattutto perché utilizzando un laptop ritenevo un inutile spreco di <span style="text-decoration: line-through;">risorse</span> (leggasi batteria) avviare tutto l&#8217;ambaradan per (ad esempio) modificare qualche piccolo file o effettuare qualche piccola operazione.<br />
E poi voglio far vedere a tutti il mio favoloso issue <img src='http://www.ldlabs.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley colorbox-8' /> </p>
<p>da sempre quindi disattivo questo tipo di applicativi preferendo un più semplice login da terminale (tty) e poi (all&#8217;occorrenza) avviare x tramite il comando <em>`startx</em>`.</p>
<p>Per vari motivi ho deciso di muovere un ulteriore passo dato che iniziavo a digitare ad ogni avvio quel comando:<em><br />
pe</em><em>rchè non posso avviare X automaticamente dopo aver effettuato il login ad esempio dalla tty1?</em></p>
<p>Bene, la soluzione è tutto sommato semplice, ho creato uno scriptino che effettua dei controlli (se eventualmente il server X è già attivo e se è tutto ok allora lancio X tramite startx appunto.<br />
Eccolo qui:</p>

<div class="wp_codebox"><table><tr id="p814"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code" id="p8code14"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> check <span style="color: #7a0874; font-weight: bold;">&#123;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">login</span> <span style="color: #7a0874; font-weight: bold;">&#93;</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: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>.X0-lock <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">login</span>
<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">else</span>
<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">else</span>
<span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">login</span>
<span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
check
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-eq</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
&nbsp;
startx <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
&nbsp;
<span style="color: #000000; font-weight: bold;">fi</span></pre></td></tr></table></div>

<p>Successivamente c&#8217;è da modificare <em>.bashrc</em> e metterci un ulteriore controllo e richiamare lo script:</p>

<div class="wp_codebox"><table><tr id="p815"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p8code15"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TERM</span>&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
linux<span style="color: #7a0874; font-weight: bold;">&#41;</span> ~<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>startx.sh <span style="color: #000000; font-weight: bold;">&amp;</span> <span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">esac</span></pre></td></tr></table></div>

<p>ovviamente <em>~/bin/startx.sh</em> è il path completo allo script precedentemente creato.</p>
<p>Infine non ci resta che editare (da root) il file  <em>/etc/X11/Xwrapper.conf</em> settando come <em>allowed_users=anybody</em></p>
<p>Ecco fatto ora tutto funziona alla perfezione.</p>
<div id="bottomcontainerBox">
			<div class="buttons">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.ldlabs.org%2Fblog%2F2009%2F02%2F05%2Fxttydm%2F&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe></div>
			<div class="buttons">
			<g:plusone size="medium" href="http://www.ldlabs.org/blog/2009/02/05/xttydm/"></g:plusone>
			</div>
			<div class="buttons">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.ldlabs.org/blog/2009/02/05/xttydm/"  data-text="xttydm (aka lanciare X dopo il login da tty)" data-count="horizontal">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://www.ldlabs.org/blog/2009/02/05/xttydm/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

