<?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>Developers, Developers, Developers! &#187; shell scripts</title>
	<atom:link href="http://maksim.sorokin.dk/it/tag/shell-scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://maksim.sorokin.dk/it</link>
	<description>Maksim Sorokin IT Blog</description>
	<lastBuildDate>Sun, 05 Feb 2012 19:37:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
		<item>
		<title>IzPack: Thoughts on Using Environmental Variables in Silent Installation</title>
		<link>http://maksim.sorokin.dk/it/2010/07/27/izpack-thoughts-on-using-environmental-variables-in-silent-installation/</link>
		<comments>http://maksim.sorokin.dk/it/2010/07/27/izpack-thoughts-on-using-environmental-variables-in-silent-installation/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 15:48:19 +0000</pubDate>
		<dc:creator>Maksim Sorokin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[BAT]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[IzPack]]></category>
		<category><![CDATA[shell scripts]]></category>
		<category><![CDATA[silent installation]]></category>

		<guid isPermaLink="false">http://maksim.sorokin.dk/it/?p=302</guid>
		<description><![CDATA[IzPack is pretty powerful installation tool. However, silent installation (or the call it Automated Installers) lacks some flexibility. One of the things, which I lack, is a possibility to provide environmental variables in silent installation configuration files (auto-install.xml). Here I will provide some tricks which would help making your installer "eat" silent installation configuration files [...]]]></description>
			<content:encoded><![CDATA[<p>IzPack is pretty powerful installation tool. However, silent installation (or the call it <a href="http://izpack.org/documentation/advanced-features.html#automated-installers">Automated Installers</a>) lacks some flexibility. One of the things, which I lack, is a possibility to provide environmental variables in silent installation configuration files (<code>auto-install.xml</code>). Here I will provide some tricks which would help making your installer "eat" silent installation configuration files <em>with</em> environmental variables.</p>
<p>To start with, <span id="more-302"></span> I will notice that in <code>installpath</code> you can always use <a href="http://izpack.org/documentation/installation-files.html#environment-variables">IzPack way of interpreting environmental variables</a>. For example:</p>
<pre class="brush: xml; title: ;">
&lt;installpath&gt;${ENV[APPDATA]}\3Dfacto\installers\glassfish&lt;/installpath&gt;
</pre>
<p>Next, ordinary IzPack variables to be used in BAT files.<br />
In your silent configuration files you would like to see something like:</p>
<pre class="brush: xml; title: ;">
&lt;AutomatedInstallation langpack=&quot;eng&quot;&gt;
   ...
  &lt;com.izforge.izpack.panels.UserInputPanel id=&quot;UNKNOWN (com.izforge.izpack.panels.UserInputPanel)&quot;&gt;
    &lt;userInput&gt;
      &lt;entry key=&quot;myVar&quot; value=&quot;%HOMEDRIVE%\location\file.txt&quot;/&gt;
   ...
&lt;/AutomatedInstallation&gt;
</pre>
<p>Here are some ideas which may help you make it work.</p>
<p>Now, when you use <a href="http://izpack.org/documentation/panels.html#processpanel">ProcessPanel</a> to launch your bat file, you pass a environmental variable inside a variable. Once you realize it, it is easy to make small trick to make everything work. For example, if in silent installation configuration file (in example above), you provide environmental variable to <code>myVar</code> variable. And then you pass it to the bat file with <code>ProcessPanel</code> in <code>processPanelSpec.xml</code>:</p>
<pre class="brush: xml; title: ;">
&lt;processing&gt;
  &lt;job name=&quot;Install configuratorPortal&quot;&gt;
    &lt;executefile name=&quot;$INSTALL_PATH/script.bat&quot;&gt;
      &lt;env&gt;myVar=$myVar&lt;/env&gt;
  ...
&lt;/processing&gt;
</pre>
<p>When <code>ProcessPanel</code> launches that bat file, your <code>myVar</code> will be substituted once. But you need to get it substituted two times! What you may do is to simply add shell <code>call</code> command in front of the expression, where <code>myVar</code> is used. In this case, variable will be substituted twice.<br />
However, it will not work in some cases, for example:</p>
<pre class="brush: plain; title: ;">call echo hi&gt; %myVar%</pre>
<p>or</p>
<pre class="brush: plain; title: ;">call if exist %myVar% echo &quot;hi&quot;</pre>
<p>What you can do in this case is to use a wrapper. For instance, if you want to call <code>echo</code> command to substitute variable twice:</p>
<pre class="brush: plain; title: ;">call echo hi&gt; %myVar%</pre>
<p>Then create a helper <code>parameterDumper.bat</code>:</p>
<pre class="brush: plain; title: ;">
echo off

:: %1 -- what
:: %2 -- where

call echo %~1&amp;gt;&amp;gt; %~2
</pre>
<p>Include it into installation and simply call that instead:</p>
<pre class="brush: plain; title: ;">call &quot;%INSTALL_PATH%\parameterDumper.bat&quot; &quot;hi&quot; &quot;%myVar%&quot;</pre>
<p>Then two <code>call</code> commands will be executed and the parameter will be evaluated twice.</p>
]]></content:encoded>
			<wfw:commentRss>http://maksim.sorokin.dk/it/2010/07/27/izpack-thoughts-on-using-environmental-variables-in-silent-installation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Power of Shell Scripts</title>
		<link>http://maksim.sorokin.dk/it/2010/07/21/the-power-of-shell-scripts/</link>
		<comments>http://maksim.sorokin.dk/it/2010/07/21/the-power-of-shell-scripts/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 17:36:21 +0000</pubDate>
		<dc:creator>Maksim Sorokin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[general]]></category>
		<category><![CDATA[shell scripts]]></category>

		<guid isPermaLink="false">http://maksim.sorokin.dk/it/?p=286</guid>
		<description><![CDATA[I love nice and clean solutions. But also, I love workarounds and tricky hacks which just make things work. In my world there is plenty of legacy code and urgent jobs which need to be done this minute. Sometimes it is obvious to see, that solution is one-time or temporary (although sometimes it is turns [...]]]></description>
			<content:encoded><![CDATA[<p>I love nice and clean solutions. But also, I love workarounds and tricky hacks which just make things work. In my world there is plenty of legacy code and urgent jobs which need to be done this minute. Sometimes it is obvious to see, that solution is one-time or temporary (although sometimes it is turns out, that it works for muuuch longer time <img src='http://maksim.sorokin.dk/it/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ) ), but time is pressing and there is only an option of no solution or dirty solution..</p>
<p> And here comes the power of shell scripts! Some old nasty application runs out of memory every second day? Then what about just restarting it every night? Some third party software results in PermGen errors on high inputs? What about passing data in chunks? There are plenty of things you can do with them! But never use it for long-term solutions!</p>
]]></content:encoded>
			<wfw:commentRss>http://maksim.sorokin.dk/it/2010/07/21/the-power-of-shell-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

