<?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>Fabio Falcinelli &#187; Development</title>
	<atom:link href="http://www.fabiofalcinelli.it/category/information-technology/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.fabiofalcinelli.it</link>
	<description>A mix of code and photos...</description>
	<lastBuildDate>Sat, 29 May 2010 12:16:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>JNI su HP-UX, le dimensioni dello stack contano</title>
		<link>http://www.fabiofalcinelli.it/2010/03/jni-su-hp-ux-le-dimensioni-dello-stack-contano/</link>
		<comments>http://www.fabiofalcinelli.it/2010/03/jni-su-hp-ux-le-dimensioni-dello-stack-contano/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 18:39:00 +0000</pubDate>
		<dc:creator>Fabio</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Information Technology]]></category>
		<category><![CDATA[Photography]]></category>
		<category><![CDATA[Stuff]]></category>
		<category><![CDATA[BoKS]]></category>
		<category><![CDATA[HP-UX]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JNI]]></category>
		<category><![CDATA[pthread]]></category>
		<category><![CDATA[Stacksize]]></category>
		<category><![CDATA[tusc]]></category>

		<guid isPermaLink="false">http://www.fabiofalcinelli.it/?p=355</guid>
		<description><![CDATA[Arrugginito forse un po&#8217;, quando si passa tanto tempo a fare altro ci si dimentica di avere anche uno spazio web dove annotare quei piccoli successi che potrebbero tornare utili ad altri, ma anche a te semmai te ne dovessi dimenticare :) Il problema di fondo era che la chiamata JNI_CreateJavaVM produceva il segnale SIGABRT [...]]]></description>
			<content:encoded><![CDATA[<p>Arrugginito forse un po&#8217;, quando si passa tanto tempo a fare altro ci si dimentica di avere anche uno spazio web dove annotare quei piccoli successi che potrebbero tornare utili ad altri, ma anche a te semmai te ne dovessi dimenticare :)</p>
<p>Il problema di fondo era che la chiamata JNI_CreateJavaVM produceva il segnale SIGABRT quando invocato all&#8217;interno di un altro framework, nello specifico stavo utilizzando l&#8217;SDK BoKS.</p>
<p>La porzione di codice interessata, a parte dovuti accorgimenti, era del tutto coerente con quanto riportato da HP al link</p>
<p><a href="http://www.docs.hp.com/en/JAVAPROGUIDE/JNI_java2.html" target="_blank">http://www.docs.hp.com/en/JAVAPROGUIDE/JNI_java2.html</a></p>
<p>Provando ad utilizzare i parametri di inizializzazione della VM più svariati non si è cavato un ragno dal buco, seguendo comunque le linee guida riportate qui <a href="http://www.docs.hp.com/en/JAVAPROGUIDE/JNI_java2.html#primordial ">http://www.docs.hp.com/en/JAVAPROGUIDE/JNI_java2.html#primordial</a>, si è ipotizzato da subito un problema con lo stacksize su HP-UX, su Solaris, infatti, non erano stati riscontrati problemi di sorta.</p>
<p>Una sessione con <strong>tusc</strong> ha confermato quanto supposto:</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">19196</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #666666; font-style: italic;">#6 kwakeup(PTH_CONDVAR_OBJECT, 0x60000000000ea400, WAKEUP_ONE, 0x9fffffff7f63cb50) = 0</span><br />
<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">19196</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #666666; font-style: italic;">#2 ksleep(PTH_CONDVAR_OBJECT, 0x60000000000ea400, 0x60000000000d75b8, NULL) = 0</span><br />
<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">19196</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #666666; font-style: italic;">#6 gettimeofday(0x9fffffff7f63cb30, NULL) ........ = 0</span><br />
<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">19196</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #666666; font-style: italic;">#2 write(1, 0x9fffffffef4c0400, 43) .............. = 43</span><br />
E r r o r &nbsp; o c c u r r e d &nbsp; d u r i n g &nbsp; i n i t i a l i z a<br />
t i o n &nbsp; o f &nbsp; V M \n<br />
<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">19196</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #666666; font-style: italic;">#2 write(1, 0x60000000001683a0, 28) .............. = 28</span><br />
j a v a . l a n g . S t a c k O v e r f l o <span style="color: #c20cb9; font-weight: bold;">w</span> E r r o r<br />
<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">19196</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #666666; font-style: italic;">#2 write(1, 0xc000000015cf08b8, 1) ............... = 1</span><br />
\n<br />
<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">19196</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #666666; font-style: italic;">#2 unlink(&quot;/var/tmp/hsperfdata_boksa/19196&quot;) ..... = 0</span><br />
<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">19196</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #666666; font-style: italic;">#2 sigaction(SIGILL, 0x9fffffffef7c6740, NULL) ... = 0</span><br />
<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">19196</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #666666; font-style: italic;">#2 sigprocmask(SIG_UNBLOCK, NULL, 0x9fffffffef4c0b80) = 0</span><br />
<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">19196</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #666666; font-style: italic;">#2 sigaction(SIGABRT, NULL, 0x9fffffffef4c0ba0) .. = 0</span><br />
<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">19196</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #666666; font-style: italic;">#2 getpid() ...................................... = 19196 (19194)</span><br />
<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">19196</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #666666; font-style: italic;">#2 &nbsp; Received signal 6, SIGABRT, in kill(), [0x9fffffffef76bfd0]</span><br />
<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">19196</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #666666; font-style: italic;">#2 &nbsp; &nbsp; Siginfo: sent by pid 19196 (uid 600), si_errno: 0</span></div></div>
<p>La soluzione?</p>
<p>Un semplice export della variabile <strong>PTHREAD_DEFAULT_STACK_SIZE</strong> a <strong>524288</strong>.</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PTHREAD_DEFAULT_STACK_SIZE</span>=<span style="color: #000000;">524288</span></div></div>
<p>Si sarebbe anche potuta usare la chiamata pthread_default_stacksize_np(), ma poiché la parte di codice che crea i thread non è personalizzabile in quel dato SDK, l&#8217;export della variabile d&#8217;ambiente è stata l&#8217;unica soluzione attuabile.</p>
<p>Alla prossima!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fabiofalcinelli.it/2010/03/jni-su-hp-ux-le-dimensioni-dello-stack-contano/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VirtualBox &#8211; Error 1603</title>
		<link>http://www.fabiofalcinelli.it/2009/11/virtualbox-error-1603/</link>
		<comments>http://www.fabiofalcinelli.it/2009/11/virtualbox-error-1603/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 20:05:55 +0000</pubDate>
		<dc:creator>Fabio</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Information Technology]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.fabiofalcinelli.it/?p=346</guid>
		<description><![CDATA[Era un po&#8217; di tempo che non battevo qualche tasto da queste parti&#8230; Torno con qualcosa di utile, spero, una soluzione semplice ad un problema che mi ha fatto perdere non poco tempo. Per le foto&#8230; Beh ultimamente sono un po&#8217; a digiuno, presto finirò di riempire queste pagine, sperando di riuscire a tirarne fuori [...]]]></description>
			<content:encoded><![CDATA[<p>Era un po&#8217; di tempo che non battevo qualche tasto da queste parti&#8230; Torno con qualcosa di utile, spero, una soluzione semplice ad un problema che mi ha fatto perdere non poco tempo. Per le foto&#8230; Beh ultimamente sono un po&#8217; a digiuno, presto finirò di riempire queste pagine, sperando di riuscire a tirarne fuori una degna di nota!</p>
<p>Avere a disposizione una macchina virtuale ha numerosi vantaggi, e VirtualBox è una scelta da non trascurare, gratuito per uso personale (licenza PUEL), veramente semplice da usare e multipiattaforma. Lo uso tranquillamente su OSX e Archlinux, su Windows XP&#8230; Non proprio! :)</p>
<p>Volevo aggiornare alla versione 3.0.1, ma il risultato dell&#8217;installer era sempre il seguente &#8220;VirtualBox setup ended prematurely&#8221; seguito da un &#8220;Error 1603&#8243;. Anche la disinstallazione della versione precedente (2.2) non dava cenni di voler funzionare, di fatto sia l&#8217;installazione di una nuova versione che la rimozione della vecchia si interrompevano portando al rollback delle modifiche.</p>
<p>Rimuovendo tutti i file dalla directory &#8220;Programmi&#8221;, eliminando i riferimenti dal registro (quelli che sono riuscito ad individuare), disinstallando le interfacce di rete virtuali e cancellando anche i loro driver non sono riuscito ad ottenere altro che  un nulla di fatto.</p>
<p>Alla fine ho trovato questo articolo http://www.virtualbox.org/ticket/3701 e riporto di seguito quello che ho fatto anche io per risolvere:</p>
<p>1. tasto windows+r -&gt; regedit ;<br />
2. Export della chiave HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\DIFxApp\Components su un file qualsiasi per comodità sul desktop (per esempio vbox.reg);<br />
3. Sostituzione di tutte le occorrenze di HKEY_CURRENT_USER all&#8217;interno del file con HKEY_LOCAL_MACHINE in modo da ottenere il file come di seguito:</p>
<div class="codecolorer-container text twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Windows Registry Editor Version 5.00<br />
<br />
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\DIFxApp\Components]<br />
<br />
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\DIFxApp\Components\{010FE46A-E358-43E2-8BDC-38BC8BEC82E0}]<br />
&quot;CleanupNeeded&quot;=dword:00000001<br />
&quot;Reboot&quot;=dword:00000000<br />
<br />
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\DIFxApp\Components\{7ADF3E12-AF3C-4D36-8BEC-36D5064CF84F}]<br />
<br />
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\DIFxApp\Components\{AC3FB68C-FE7D-40FC-BFF4-3A6B3B41513B}]<br />
<br />
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\DIFxApp\Components\{B7D782D2-96DF-4775-A0E1-A76CF7B04B65}]<br />
&quot;CleanupNeeded&quot;=dword:00000001<br />
&quot;Reboot&quot;=dword:00000000<br />
<br />
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\DIFxApp\Components\{BC01FCCB-D7AB-4ADB-9657-B6F7ED514715}]<br />
&quot;CleanupNeeded&quot;=dword:00000001<br />
&quot;Reboot&quot;=dword:00000000<br />
<br />
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\DIFxApp\Components\{D3E2F2BB-569F-46A2-836C-BDF30FF1EDF8}]</div></div>
<p>4. Import del file .reg nel registro (basta un doppio click sul file);<br />
<strong>5. Rimozione della chiave HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\DIFxApp ;</strong></p>
<p>Dopo il passo 5 l&#8217;installazione della versione 3 è andata senza alcun problema.</p>
<p>Alla prossima! :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fabiofalcinelli.it/2009/11/virtualbox-error-1603/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Shutdown HSQLDB</title>
		<link>http://www.fabiofalcinelli.it/2009/05/shutdown-hsqldb/</link>
		<comments>http://www.fabiofalcinelli.it/2009/05/shutdown-hsqldb/#comments</comments>
		<pubDate>Sat, 23 May 2009 09:35:43 +0000</pubDate>
		<dc:creator>Fabio</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Information Technology]]></category>
		<category><![CDATA[Landscapes]]></category>
		<category><![CDATA[Photography]]></category>
		<category><![CDATA[Calabria]]></category>
		<category><![CDATA[Fiumefreddo Bruzio]]></category>
		<category><![CDATA[HSQLDB]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JDBC]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Tramonto]]></category>

		<guid isPermaLink="false">http://www.fabiofalcinelli.it/?p=221</guid>
		<description><![CDATA[Ultimamente sto usando Hypersonic SQL DB in un software che sto scrivendo. Il driver utilizzato è &#8220;embedded&#8221; ovvero non è presente un server in attesa di ricevere comandi SQL, ma il database è un file gestito direttamente dal driver di hypersonic. Con questo tipo di accesso però, avevo notato perdite di dati sul database, non [...]]]></description>
			<content:encoded><![CDATA[<p>Ultimamente sto usando Hypersonic SQL DB in un software che sto scrivendo. Il driver utilizzato è &#8220;<em>embedded</em>&#8221; ovvero non è presente un server in attesa di ricevere comandi SQL, ma il database è un file gestito direttamente dal driver di hypersonic.</p>
<p>Con questo tipo di accesso però, avevo notato perdite di dati sul database, non tutto infatti diventava persistente e, certo di non aver scritto codice errato, iniziavo a pensare di non capirci più nulla.</p>
<p>Il fatto è che, a differenza di quanto ero solito fare con altri RDBMS, non è sufficiente chiudere una connessione con</p>
<div class="codecolorer-container java twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">connection.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></div></div>
<p>al termine dell&#8217;esecuzione del programma, il driver effettua caching delle tabelle per ottimizzare gli accessi al file system e non tutte le modifiche vengono scritte sul file.</p>
<p>È necessario fornire al driver l&#8217;istruzione di &#8220;SHUTDOWN&#8221; di modo che tutti i dati eventualmente ancora in cache vengano correttamente resi persistenti:</p>
<div class="codecolorer-container java twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003399;">Statement</span> shutdown <span style="color: #339933;">=</span> connection.<span style="color: #006633;">createStatement</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SHUTDOWN&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
shutdown.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
shutdown.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
connection.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>Esiste inoltre, una funzione di shutdown che effettua anche una riorganizzazione del database ed una compressione dei dati. Essendo un&#8217;operazione lenta è bene non usarla troppo di frequente, il criterio d&#8217;uso è lo stesso di &#8220;SHUTDOWN&#8221;, &#8220;SHUTDOWN COMPACT&#8221;.</p>
<p>Alla prossima :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fabiofalcinelli.it/2009/05/shutdown-hsqldb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Elementary su Windows XP</title>
		<link>http://www.fabiofalcinelli.it/2009/05/elementary-su-windows-xp/</link>
		<comments>http://www.fabiofalcinelli.it/2009/05/elementary-su-windows-xp/#comments</comments>
		<pubDate>Thu, 14 May 2009 12:17:02 +0000</pubDate>
		<dc:creator>Fabio</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Information Technology]]></category>
		<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[E17]]></category>
		<category><![CDATA[Elementary]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[XP]]></category>

		<guid isPermaLink="false">http://www.fabiofalcinelli.it/?p=217</guid>
		<description><![CDATA[Finalmente ci sono riuscito dopo un po&#8217; di manodopera :) Per poter utilizzare elementary dovrete prima aver installato le EFL (Enlightenment Foundation Libraries). Seguite il wiki al link di seguito http://trac.enlightenment.org/e/wiki/EFLWindowsXP Compilate anche elementary col solito ./autogen.sh make make install e ricordatevi di impostare la variabile d&#8217;ambiente ELM_ENGINE con set ELM_ENGINE=ddraw Eseguite elementary_test per vedere [...]]]></description>
			<content:encoded><![CDATA[<p>Finalmente ci sono riuscito dopo un po&#8217; di manodopera :)</p>
<p>Per poter utilizzare elementary dovrete prima aver installato le <strong>EFL</strong> (<em>Enlightenment Foundation Libraries</em>). Seguite il wiki al link di seguito</p>
<p><a title="EFL Windows XP" href="http://trac.enlightenment.org/e/wiki/EFLWindowsXP" target="_blank">http://trac.enlightenment.org/e/wiki/EFLWindowsXP</a></p>
<p>Compilate anche <em>elementary</em> col solito</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">.<span style="color: #000000; font-weight: bold;">/</span>autogen.sh<br />
<span style="color: #c20cb9; font-weight: bold;">make</span><br />
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></div></div>
<p>e ricordatevi di impostare la variabile d&#8217;ambiente ELM_ENGINE con</p>
<div class="codecolorer-container text twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">set ELM_ENGINE=ddraw</div></div>
<p>Eseguite <em>elementary_test</em> per vedere che sia tutto ok e il risultato dovrebbe essere il seguente</p>
<div id="attachment_216" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.fabiofalcinelli.it/wp-content/uploads/2009/05/elm_win_xp.png" rel="lightbox[217]"><img class="size-medium wp-image-216" title="elm_win_xp" src="http://www.fabiofalcinelli.it/wp-content/uploads/2009/05/elm_win_xp-300x187.png" alt="elementary on windows xp" width="300" height="187" /></a><p class="wp-caption-text">elementary on windows xp</p></div>
<p>Se qualcosa non va, probabilmente siete incappati nel mio stesso errore: aver compilato evas senza il supporto al ddraw. Ricompilate evas aggiungendo l&#8217;opzione <strong>&#8211;enable-software-ddraw</strong>. Io ho usato i seguenti:</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">.<span style="color: #000000; font-weight: bold;">/</span>autogen.sh &nbsp;<span style="color: #660033;">--enable-sdl</span> <span style="color: #000000; font-weight: bold;">/</span><br />
<span style="color: #660033;">--enable-gl-glew</span> <span style="color: #000000; font-weight: bold;">/</span><br />
<span style="color: #660033;">--enable-direct3d</span> <span style="color: #000000; font-weight: bold;">/</span><br />
<span style="color: #660033;">--enable-software-ddraw</span> <span style="color: #000000; font-weight: bold;">/</span><br />
<span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></div></div>
<p>Adesso posso iniziare a sviluppare qualcosa che sia crossplatform e che usi un&#8217;interfaccia grafica gradevole. Cosa però? Mi verrà l&#8217;ispirazione penso&#8230; Prima o poi&#8230; :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fabiofalcinelli.it/2009/05/elementary-su-windows-xp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compilare E17 da SVN su Archlinux</title>
		<link>http://www.fabiofalcinelli.it/2009/05/compilare-e17-da-svn-su-archlinux/</link>
		<comments>http://www.fabiofalcinelli.it/2009/05/compilare-e17-da-svn-su-archlinux/#comments</comments>
		<pubDate>Mon, 04 May 2009 13:16:50 +0000</pubDate>
		<dc:creator>Fabio</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Information Technology]]></category>
		<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[Archlinux]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[E17]]></category>
		<category><![CDATA[Enlightenment]]></category>
		<category><![CDATA[GPL]]></category>

		<guid isPermaLink="false">http://www.fabiofalcinelli.it/?p=210</guid>
		<description><![CDATA[Un piccolo script molto comodo che ho scritto insieme a furester, per compilare E17 scaricando i sorgenti da SVN. Lo script utilizza il sistema di porting di Archlinux ed ha alcuni piccoli accorgimenti che permettono di ricompilare solo i pacchetti che hanno subito modifiche. Non è pienamente testato, potrebbe contenere diversi bug, diverse funzionalità sono [...]]]></description>
			<content:encoded><![CDATA[<p>Un piccolo script molto comodo che ho scritto insieme a <a title="Xenos blog" href="http://xenos.altervista.org" target="_blank">furester</a>, per compilare E17 scaricando i sorgenti da SVN. Lo script utilizza il sistema di porting di Archlinux ed ha alcuni piccoli accorgimenti che permettono di ricompilare solo i pacchetti che hanno subito modifiche.</p>
<p>Non è pienamente testato, potrebbe contenere diversi bug, diverse funzionalità sono ancora da implementare, ma chi volesse provarlo può scaricarlo da questo link:</p>
<p><a title="archE17svn.sh" href="http://fabiofalcinelli.it/files/archE17svn.sh" target="_blank">http://fabiofalcinelli.it/files/archE17svn.sh</a></p>
<p>Potete testarlo, modificarlo redistribuirlo sotto i termini della <a title="GPL" href="http://www.gnu.org/copyleft/gpl.html" target="_blank">licenza GPL</a>.</p>
<h2>Installazione</h2>
<p>Per usare lo script è sufficiente copiarlo in una qualsiasi directory. Di default lo script creerà una cartella <em>archE17svn</em> nella home dell&#8217;utente che lo esegue ed esegurà tutte le operazioni al suo interno.</p>
<h2>Configurazione</h2>
<p>Lo script accetta i seguenti parametri:<br />
<strong>-r</strong> popola un repository per pacman (non ancora implementato)<br />
<strong>-f</strong> forza la ricompilazione di tutti i pacchetti<br />
<strong>-R</strong> reinstalla la snapshot precompilata presente in <em>community</em><br />
<strong>-d</strong> compila con simboli di debug<br />
<strong> -o=name1,name2,&#8230;</strong> checkout e compilazione dei soli pacchetti elencati<br />
<strong>-w=dir</strong> cambia la directory di lavoro (il default è ~/archE17svn)<br />
<strong> -h</strong> stampa a video il messaggio di aiuto</p>
<p>Una volta compilato, potrete usare e17&#8230; Di seguito un piccolo screenshot :)</p>
<div id="attachment_213" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.fabiofalcinelli.it/wp-content/uploads/2009/05/wp.png" rel="lightbox[210]"><img class="size-medium wp-image-213" title="E17 e modulo wallpaper" src="http://www.fabiofalcinelli.it/wp-content/uploads/2009/05/wp-300x180.png" alt="e17 and wallpaper module" width="300" height="180" /></a><p class="wp-caption-text">e17 and wallpaper module</p></div>
<p>L&#8217;immagine mostra il modulo wallapaper che permette la configurazione dello sfondo del window manager. La cosa veramente interessante del modulo è l&#8217;ordinamento in scala cromatica delle immagini: ho sempre pensato che ordinare le immagini in base al nome (quindi in ordine alfabetico) non abbia molto senso e questo modulo ne è la prova.</p>
<p>Per vedere il modulo in azione, potete visualizzare il video al link sottostante</p>
<p><a title="Wallpaper module" href="http://www.rasterman.com/files/wp2.avi" target="_blank">http://www.rasterman.com/files/wp2.avi</a></p>
<p>Alla prossima!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fabiofalcinelli.it/2009/05/compilare-e17-da-svn-su-archlinux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://www.rasterman.com/files/wp2.avi" length="27264116" type="video/x-msvideo" />
		</item>
		<item>
		<title>Aggiungere il timestamp ad ogni riga in output</title>
		<link>http://www.fabiofalcinelli.it/2009/04/aggiungere-il-timestamp-ad-ogni-riga-in-output/</link>
		<comments>http://www.fabiofalcinelli.it/2009/04/aggiungere-il-timestamp-ad-ogni-riga-in-output/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 17:21:41 +0000</pubDate>
		<dc:creator>Fabio</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Information Technology]]></category>
		<category><![CDATA[Awk]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[SVN]]></category>
		<category><![CDATA[UNIX]]></category>

		<guid isPermaLink="false">http://www.fabiofalcinelli.it/?p=150</guid>
		<description><![CDATA[Eccomi di ritorno! È passato un po&#8217; di tempo dall&#8217;ultimo post, un po&#8217; per impegni vari, un po&#8217; per pigrizia ed un po&#8217; per i tempi di attivazione del dominio (fabiofalcinelli.it). Come va? Come state? :) Vi descrivo di cosa avevo bisogno e di come ho risolto. Supponiamo di avere un programma che generi output, [...]]]></description>
			<content:encoded><![CDATA[<p>Eccomi di ritorno! È passato un po&#8217; di tempo dall&#8217;ultimo post, un po&#8217; per impegni vari, un po&#8217; per pigrizia ed un po&#8217; per i tempi di attivazione del dominio (fabiofalcinelli.it). Come va? Come state? :)</p>
<p>Vi descrivo di cosa avevo bisogno e di come ho risolto. Supponiamo di avere un programma che generi output, ma che questo output sia sprovvisto di timestamp. Se il programma deve essere eseguito ad intervalli regolari diventa un po&#8217; difficile capire cosa sta succedendo analizzandone l&#8217;output che ne è stato eventualmente redirezionato su un file.</p>
<p>Se invece di redirezionarlo direttamente al file, lo diamo prima in pasto ad <em>awk</em> sarà però possibile aggiungere, per ogni riga, il timestamp di generazione della riga stessa. Ecco di seguito come, utilizzando il tool <em>svnsync</em> come esempio:</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">svnsync</span> synchronize <span style="color: #c20cb9; font-weight: bold;">svn</span>:<span style="color: #000000; font-weight: bold;">//</span>127.0.0.1:<span style="color: #000000;">8081</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">nawk</span> <span style="color: #ff0000;">'{ <br />
&quot;date \&quot;+%a %b %d %Y %H:%M:%S -\&quot;&quot; | <br />
getline systemDate; <br />
close (&quot;date \&quot;+%a %b %d %Y %H:%M:%S -\&quot;&quot;) ; <br />
print systemDate, $O;<br />
}'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> svnsync.log</div></div>
<p>In realtà ho utilizzato <em>nawk</em> la cui implementazione supporta alcune funzionalità in più. Non ci dovrebbero essere problemi usando la stessa procedura con <em>gawk</em>.</p>
<p>Come al solito, spero che possa essere d&#8217;aiuto a qualcuno facendogli risparmiare qualche minuto del suo tempo :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fabiofalcinelli.it/2009/04/aggiungere-il-timestamp-ad-ogni-riga-in-output/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>La vita del web designer è difficile&#8230;</title>
		<link>http://www.fabiofalcinelli.it/2009/02/la-vita-del-web-designer-e-difficile/</link>
		<comments>http://www.fabiofalcinelli.it/2009/02/la-vita-del-web-designer-e-difficile/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 08:31:57 +0000</pubDate>
		<dc:creator>Fabio</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Information Technology]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PNG]]></category>

		<guid isPermaLink="false">http://fabiofalcinelli.netsons.org/?p=149</guid>
		<description><![CDATA[Raramente mi è capito di mettere mano a codice web, nonostante mi interessi molto la maggior parte del codice che scrivo è Java nudo e crudo oppure C. Quando capita però, mi rendo conto che la vita di un designer web è tutt&#8217;altro che facile. Lo so, per molti questo post sembrerà il classico &#8220;yet [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Raramente mi è capito di mettere mano a codice web, nonostante mi interessi molto la maggior parte del codice che scrivo è Java nudo e crudo oppure C.<br />
Quando capita però, mi rendo conto che la vita di un designer web è tutt&#8217;altro che facile. Lo so, per molti questo post sembrerà il classico &#8220;<em>yet another state-the-obvious post</em>&#8221; ma la frustrazione di dover adattare le cose perché qualcuno deliberatamente ha sfruttato la sua posizione dominante per fregarsene degli standard è alta&#8230;
</p>
<p style="text-align: justify;">Chi secondo voi se non Microsoft con il suo Internet Explorer 6?</p>
<p style="text-align: justify;">Per esempio, il fatto che non supporti nativamente il formato PNG trasparente è veramente fastidioso. GIF non è minimamente paragonabile con le sue limitazioni ed allora ho dovuto creare una semplice condizione per cui chi utilizza Explorer 6 vedrà qualcosa di diverso:</p>
<div class="codecolorer-container php twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$agent</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_USER_AGENT'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">eregi</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;msie 6.0&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$agent</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><br />
<br />
&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<br />
&nbsp; &nbsp;&lt;img src=&quot;/immagini/logo_ie6.jpg&quot; border=&quot;0&quot; alt=&quot;&quot; /&gt;<br />
&lt;/a&gt;<br />
<br />
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<br />
&nbsp; &nbsp;&lt;img src=&quot;/immagini/logo.png&quot; border=&quot;0&quot; alt=&quot;&quot; /&gt;<br />
&lt;/a&gt;<br />
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></div></div>
<p style="text-align: justify;">C&#8217;è anche una soluzione lato client, utilizzando Javascript, che potete trovare a <a title="Internet Explorer 6 PNG patch" href="http://www.flyonthenet.com/articoli/javascript-ajax/png-trasparenti-in-internet-explorer-6.html" target="_blank">questo indirizzo</a>, ma per il mio scopo di cambiare solo una immagine di testata è stata sufficiente la soluzione di prima, che non esegue nulla lato client.</p>
<p style="text-align: justify;">Molti sono i browser in circolazione ed utilizzare la variabile &#8216;HTTP_USER_AGENT&#8217; per distinguere l&#8217;uno dall&#8217;altro è la scelta più semplice, sebbene non sia affidabile: è possibile mascherare e cambiare tale variabile, alcuni proxy la filtrano&#8230; La soluzione? Solo il rispetto degli standard.</p>
<p style="text-align: justify;">Fortunatamente browser come Firefox e Opera prendono piede sempre più, Chrome si arrampica ed Internet Explorer 7 anche sembra aver intrapreso la strada della standardizzazione. </p>
<p><del datetime="2009-06-06T20:01:36+00:00">Perdonate il tag</p>
<div class="codecolorer-container php twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?</span>php<span style="color: #339933;">&gt;</span></div></div>
<p>ma il plugin che uso sembra avere ancora qualche problema. Vedremo se si potrà risolvere anche questo :)</del><br />
Il plugin &#8220;<em>CodeColorer</em>&#8221; lo risolve egregiamente direi :D</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fabiofalcinelli.it/2009/02/la-vita-del-web-designer-e-difficile/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Java &#8211; Esecuzione comandi su CLI parte II</title>
		<link>http://www.fabiofalcinelli.it/2009/02/java-esecuzione-comandi-su-cli-part-ii/</link>
		<comments>http://www.fabiofalcinelli.it/2009/02/java-esecuzione-comandi-su-cli-part-ii/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 20:24:08 +0000</pubDate>
		<dc:creator>Fabio</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Information Technology]]></category>
		<category><![CDATA[Deadlock]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[UNIX]]></category>

		<guid isPermaLink="false">http://fabiofalcinelli.netsons.org/?p=132</guid>
		<description><![CDATA[Se vi ricordate di un pezzo di codice scritto da me e che funzionava particolarmente bene per invocare comandi su UNIX&#8230; Beh&#8230; Scordatevelo! O meglio, dovrete fare qualche piccola modifica. Il codice in questione sembra, infatti, causare un piccolo problema chiamato deadlock. La cosa non si presenta sempre, ma dipende fortemente dalla quantità di output [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Se vi ricordate di un <a title="Java - Esecuzione comandi su CLI" href="http://fabiofalcinelli.netsons.org/2009/01/java-esecuzione-comandi-su-cli/" target="_blank">pezzo di codice scritto da me</a> e che funzionava particolarmente bene per invocare comandi su UNIX&#8230; Beh&#8230; Scordatevelo! O meglio, dovrete fare qualche piccola modifica.</p>
<p style="text-align: justify;">Il codice in questione sembra, infatti, causare un piccolo problema chiamato <em>deadlock</em>.</p>
<p style="text-align: justify;">La cosa non si presenta sempre, ma dipende fortemente dalla quantità di output che genera il comando e da come il sistema operativo gestisce il buffering della system call &#8220;write&#8221;. Lanciando <em>truss</em> da dentro al codice java, infatti, notavo che l&#8217;esecuzione delle system call si bloccava in attesa:</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ioctl<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span>, TCGETA, 0xFFBEDF34<span style="color: #7a0874; font-weight: bold;">&#41;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Err<span style="color: #666666; font-style: italic;">#22 EINVAL</span><br />
fstat64<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span>, 0xFFBEDFA8<span style="color: #7a0874; font-weight: bold;">&#41;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = <span style="color: #000000;">0</span><br />
brk<span style="color: #7a0874; font-weight: bold;">&#40;</span>0x00068A70<span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = <span style="color: #000000;">0</span><br />
brk<span style="color: #7a0874; font-weight: bold;">&#40;</span>0x0006AA70<span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = <span style="color: #000000;">0</span><br />
<span style="color: #c20cb9; font-weight: bold;">write</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span>, <span style="color: #ff0000;">&quot; D A T A &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&quot;</span>.., <span style="color: #000000;">5120</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>&nbsp; &nbsp; = <span style="color: #000000;">5120</span><br />
<span style="color: #c20cb9; font-weight: bold;">write</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span>, <span style="color: #ff0000;">&quot; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * - &gt; *&quot;</span>.., <span style="color: #000000;">5120</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>&nbsp; &nbsp; = <span style="color: #000000;">5120</span><br />
llseek<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">0</span>, <span style="color: #000000;">0</span>, SEEK_CUR<span style="color: #7a0874; font-weight: bold;">&#41;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Err<span style="color: #666666; font-style: italic;">#29 ESPIPE</span><br />
<span style="color: #c20cb9; font-weight: bold;">write</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span>, <span style="color: #ff0000;">&quot; * - &gt; * * * * * &nbsp; &nbsp; &nbsp; &nbsp;&quot;</span>.., <span style="color: #000000;">635</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>sleeping...<span style="color: #7a0874; font-weight: bold;">&#41;</span></div></div>
<p style="text-align: justify;">Non è stato facilissimo arrivare alla causa, il metodo è infatti molto semplice, ma adesso che ho identificato il problema l&#8217;errore appare quasi evidente. Il problema risiede infatti nel canale di <em>standard error </em>letto prima dello <em>standard output</em>:</p>
<ol style="text-align: justify;">
<li>Prima di poter leggere lo standard error è necessario che il processo che esegue il comando termini, e non è detto che vi siano errori;</li>
<li>Prima di poter avere tutto l&#8217;output disponibile c&#8217;è bisogno di qualcuno che consumi i dati nel buffer, ma quel qualcuno è in attesa sullo standard error;</li>
<li>Deadlock!</li>
</ol>
<p style="text-align: justify;">Sinceramente, questa spiegazione, seppur sensata non mi convince ancora appieno e appena avrò più tempo analizzerò meglio i trace delle system call, nonostante ciò riporto di seguito la versione del metodo che risolve il problema.</p>
<div class="codecolorer-container java twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">String</span> execCommand<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> cmd<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #003399;">String</span> result <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #003399;">String</span> temp <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #003399;">BufferedReader</span> stdout <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #003399;">BufferedReader</span> stderr <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #003399;">Process</span> proc <span style="color: #339933;">=</span> <span style="color: #003399;">Runtime</span>.<span style="color: #006633;">getRuntime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">exec</span><span style="color: #009900;">&#40;</span>cmd<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #666666; font-style: italic;">/*consume the output*/</span><br />
&nbsp; &nbsp;stdout <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BufferedReader</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">InputStreamReader</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;proc.<span style="color: #006633;">getInputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;temp <span style="color: #339933;">=</span> stdout.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span>temp<span style="color: #339933;">!=</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>result<span style="color: #339933;">==</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;result <span style="color: #339933;">=</span> temp<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;result <span style="color: #339933;">+=</span> temp<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; temp <span style="color: #339933;">=</span> stdout.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp;stdout.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #666666; font-style: italic;">/*check if errors occurred*/</span><br />
&nbsp; &nbsp;stderr <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BufferedReader</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">InputStreamReader</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; proc.<span style="color: #006633;">getErrorStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;temp <span style="color: #339933;">=</span> stderr.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>temp<span style="color: #339933;">!=</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; result <span style="color: #339933;">=</span> temp<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; temp <span style="color: #339933;">=</span> stderr.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span>temp<span style="color: #339933;">!=</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;result <span style="color: #339933;">+=</span> temp<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;temp <span style="color: #339933;">=</span> stderr.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; stderr.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">IOException</span><span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp;stderr.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #666666; font-style: italic;">/*if no exceptions occurred then proceed to return the output*/</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">return</span> result<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p style="text-align: justify;">Questo è quanto, il metodo main d&#8217;esempio del post precedente però è ancora valido :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fabiofalcinelli.it/2009/02/java-esecuzione-comandi-su-cli-part-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Statement vs PreparedStatement</title>
		<link>http://www.fabiofalcinelli.it/2009/01/statement-vs-preparedstatement/</link>
		<comments>http://www.fabiofalcinelli.it/2009/01/statement-vs-preparedstatement/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 12:50:49 +0000</pubDate>
		<dc:creator>Fabio</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Information Technology]]></category>
		<category><![CDATA[Injection]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JDBC]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://fabiofalcinelli.netsons.org/?p=114</guid>
		<description><![CDATA[Quando frequentavo l&#8217;università mi chiedevo quale fosse effettivamente la differenza tra uno Statement e un PreparedStatement Java. Fondamentalmente mi permettevano di raggiungere lo stesso risultato in maniera lievemente diversa. In realtà i due costrutti sono molto più diversi di quanto non si creda. Ogni comando SQL ricevuto dal DBMS viene elaborato seguendo 3 fasi: Compilazione [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Quando frequentavo l&#8217;università mi chiedevo quale fosse effettivamente la differenza tra uno Statement e un PreparedStatement Java. Fondamentalmente mi permettevano di raggiungere lo stesso risultato in maniera lievemente diversa.</p>
<p style="text-align: justify;">In realtà i due costrutti sono molto più diversi di quanto non si creda. Ogni comando SQL ricevuto dal DBMS viene elaborato seguendo 3 fasi:</p>
<ol style="text-align: justify;">
<li>Compilazione (parsing del comando SQL);</li>
<li>Esecuzione;</li>
<li>Fetching  (restituzione del risultato al client).</li>
</ol>
<p style="text-align: justify;">Supponendo che vengano eseguite molte operazioni, la classe PreparedStatement permette di eseguire il passo di compilazione una sola volta, la prima, e poi di aggiornarne i valori in seguito:</p>
<div class="codecolorer-container java twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003399;">PreparedStatement</span> pstmt <span style="color: #339933;">=</span> conn.<span style="color: #006633;">prepareStatement</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">&quot;SELECT * FROM TABELLA WHERE CAMPO = ?&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #003399;">Iterator</span> ricerca <span style="color: #339933;">=</span> lista.<span style="color: #006633;">iterator</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span>ricerca.<span style="color: #006633;">hasNext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp;pstmt.<span style="color: #006633;">setString</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span>, <span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#41;</span>ricerca.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #003399;">ResultSet</span> rs <span style="color: #339933;">=</span> pstmt.<span style="color: #006633;">executeQuery</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span>rs.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//Get results</span><br />
&nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp;<span style="color: #666666; font-style: italic;">//...</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p style="text-align: justify;">Questo si concretizza in un miglioramento delle performance, generalmente. Ciò non è sempre vero, ci sono altri fattori che entrano in gioco che possono rendere uno Statement più veloce di un PreparedStatement. A mio avviso anche se fosse, una leggera diminuzione di performance (che dipende moltissimo dal database utilizzato) per il PreparedStatement è sicuramente ben accetta data la sua grande flessibilità. Non solo, dalle <a title="Oracle - PreparedStatement vs Statment" href="http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.html#35_02" target="_blank">FAQ Oracle</a> ho appreso anche che ci sono dei benefici in termini di sicurezza nell&#8217;utilizzo di PreparedStatement: il binding dei dati, infatti, eviterebbe un considerevole numero di attacchi di tipo SQL Injection. La FAQ infatti riporta:</p>
<blockquote>
<p style="text-align: justify;"><em>&#8220;Statements may be slightly faster if you are only going to execute the SQL once. PreparedStatements are much faster when the SQL will be executed more than once. If you are using the statement cache, which you should, getting a statement from the cache is the same as executing the same statement.</em></p>
<p><em>In general we strongly recommend that you use PreparedStatements. This is especially true if you are sending user provided data in the SQL. By binding the data to a PreparedStatement parameter you can prevent most SQL injection attacks. Any performance advantage of using Statements is negligible.&#8221;</em></p></blockquote>
<p style="text-align: justify;">Insomma, per i miei gusti, non c&#8217;è motivo di usare Statement e PreparedStatement è la classe vincente.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fabiofalcinelli.it/2009/01/statement-vs-preparedstatement/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Java &#8211; Esecuzione comandi su CLI</title>
		<link>http://www.fabiofalcinelli.it/2009/01/java-esecuzione-comandi-su-cli/</link>
		<comments>http://www.fabiofalcinelli.it/2009/01/java-esecuzione-comandi-su-cli/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 20:50:49 +0000</pubDate>
		<dc:creator>Fabio</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Information Technology]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[UNIX]]></category>

		<guid isPermaLink="false">http://fabiofalcinelli.netsons.org/?p=85</guid>
		<description><![CDATA[Prima o poi può essere utile astrarre un po&#8217; meno dalla macchina e tornare a interfacciarsi con il Sistema Operativo sottostante. Quello che può tornare utile è quindi un metodo per eseguire comandi di sistema dalla VirtualMachine Java. Il seguente è un metodo che ho scritto in fretta e furia, ma che su sistemi UNIX [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Prima o poi può essere utile astrarre un po&#8217; meno dalla macchina e tornare a interfacciarsi con il Sistema Operativo sottostante. Quello che può tornare utile è quindi un metodo per eseguire comandi di sistema dalla VirtualMachine Java. Il seguente è un metodo che ho scritto in fretta e furia, ma che su sistemi UNIX sembra funzionare molto molto bene:</p>
<div class="codecolorer-container java twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">String</span> execCommand<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> cmd<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #003399;">String</span> result <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #003399;">BufferedReader</span> stdout <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #003399;">BufferedReader</span> stderr <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #003399;">Runtime</span> runtime <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #003399;">Process</span> proc <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp;runtime <span style="color: #339933;">=</span> <span style="color: #003399;">Runtime</span>.<span style="color: #006633;">getRuntime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;proc <span style="color: #339933;">=</span> runtime.<span style="color: #006633;">exec</span><span style="color: #009900;">&#40;</span>cmd<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;stderr <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BufferedReader</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">InputStreamReader</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; proc.<span style="color: #006633;">getErrorStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #003399;">String</span> temp <span style="color: #339933;">=</span> stderr.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #666666; font-style: italic;">/*check if errors occurred*/</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>temp<span style="color: #339933;">!=</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">do</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>result<span style="color: #339933;">==</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result <span style="color: #339933;">=</span> temp<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result <span style="color: #339933;">+=</span> temp<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;temp <span style="color: #339933;">=</span> stderr.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span>temp<span style="color: #339933;">!=</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; stderr.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">IOException</span><span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #666666; font-style: italic;">/*if no exceptions occurred then proceed to return the output*/</span><br />
&nbsp; &nbsp;stdout <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BufferedReader</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">InputStreamReader</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;proc.<span style="color: #006633;">getInputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;temp <span style="color: #339933;">=</span> stdout.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span>temp<span style="color: #339933;">!=</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>result<span style="color: #339933;">==</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;result <span style="color: #339933;">=</span> temp<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;result <span style="color: #339933;">+=</span> temp<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; temp <span style="color: #339933;">=</span> stdout.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; stdout.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">return</span> result<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p style="text-align: justify;">L&#8217;idea è semplice: se il comando fallisce, restituisco l&#8217;esito del comando (lo standard error) come un&#8217;eccezione di I/O, altrimenti il metodo torna l&#8217;esito del comando (lo standard output).</p>
<p style="text-align: justify;">A questo punto possiamo, per esempio, scrivere il seguente main, un po&#8217; inutile, ma rende l&#8217;idea</p>
<div class="codecolorer-container java twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">try</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> result <span style="color: #339933;">=</span> execCommand<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ls -lrt&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #003399;">System</span>.<span style="color: #006633;">err</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p style="text-align: justify;">Ovviamente il codice non è ottimizzato essendo la prima stesura di getto, alcune cose potevano essere evitate (i due BufferedReader per esempio), ma spero che a qualcuno questo metodo torni utile.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fabiofalcinelli.it/2009/01/java-esecuzione-comandi-su-cli/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
