<?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>Skypher &#187; batch scripts</title>
	<atom:link href="http://skypher.com/index.php/category/languages/batch-scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://skypher.com</link>
	<description>The blog for absolutely nothing!</description>
	<lastBuildDate>Sat, 19 Nov 2011 22:09:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Fix for Windows batch script arguments handling &#8220;feature&#8221;</title>
		<link>http://skypher.com/index.php/2010/08/17/batch-command-line-arguments/</link>
		<comments>http://skypher.com/index.php/2010/08/17/batch-command-line-arguments/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 15:40:54 +0000</pubDate>
		<dc:creator>SkyLined</dc:creator>
				<category><![CDATA[batch scripts]]></category>
		<category><![CDATA[Programming Languages]]></category>

		<guid isPermaLink="false">http://skypher.com/?p=494</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  preg_split() [<a href='function.preg-split'>function.preg-split</a>]: Compilation failed: lookbehind assertion is not fixed length at offset 14 in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>77</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>78</b><br />
]]></description>
			<content:encoded><![CDATA[<p>Windows is full of &#8220;features&#8221; that probably seemed like a good idea at the time but which turn out to be a mayor pain in certain situation. One of these is a feature in the handling of arguments passed to batch scripts: when you pass an argument that contains an equal sign or semicolon to a batch script, the argument gets split in two as if you had typed a space instead. Here is a simple example of a batch script that shows the first four arguments it was passed:</p>
<p><code><br />
@ECHO OFF<br />
ECHO Argument #1 = [ %1 ]<br />
ECHO Argument #2 = [ %2 ]<br />
ECHO Argument #3 = [ %3 ]<br />
ECHO Argument #4 = [ %4 ]<br />
ECHO Arguments   = [ %1 %2 %3 %4 ]<br />
&nbsp;<br />
</code></p>
<p>And here is the output of this script, when executed with quotes, equal signs and semicolons in the command-line arguments:</p>
<p><code style="color: silver; background: black"><br />
C:\&gt;test.cmd 1=not2;not3 " 2 " 3 4<br />
Argument #1 = [ 1 ]<br />
Argument #2 = [ not2 ]<br />
Argument #3 = [ not3 ]<br />
Argument #4 = [ " 2 " ]<br />
Arguments   = [ 1 not2 not3 " 2 " ]<br />
&nbsp;<br />
</code></p>
<p>This &#8220;feature&#8221; has existed since <a href="http://support.microsoft.com/kb/35938">MS-DOS</a> and apparently it got reported often enough to MS that they created <a href="http://support.microsoft.com/kb/71247">a second KB article</a> to tell you that they know it is a problem. Unfortunately, both KB articles offer no work-around. They also do not mention that this affects all versions of Windows to date as well.</p>
<p>If you use any of my tools, you may have noticed that I often allow you to specify options through command-line arguments in the form &#8220;&#8211;option=value&#8221;. If you are trying to write even the simplest batch wrapper script for any of these tools, you will immediately run into problems because of this &#8220;feature&#8221;: it is impossible for the script to know if the user typed &#8220;&#8211;option value details&#8221; or &#8220;&#8211;option=value;details&#8221; through conventional argument parsing.</p>
<p>Because I was frequently jumping through all kinds of flaming hoops to work around this &#8220;feature&#8221;, I decided to create a proper work-around to address this issue.</p>
<p><strong>The solution</strong><br />
After reading through the &#8220;help&#8221; output for most commands, I found that &#8220;help call&#8221; explains the existence of &#8220;%*&#8221;:</p>
<p><code style="color: silver; background: black"><br />
C:\&gt;help call<br />
Calls one batch program from another.<br />
&nbsp;<br />
&lt;snip&gt;<br />
    %* in a batch script refers to all the arguments (e.g. %1 %2 %3<br />
        %4 %5 ...)<br />
&lt;snip&gt;<br />
&nbsp;<br />
</code><br />
You may have noticed in my original example that &#8220;%*&#8221; retains the arguments passed to the script as is (without substituting equal signs, semicolons or any other characters for spaces). So, one solution would be to parse this string manually. In &#8220;help set&#8221; I found a way to extract a single character from a string as well as a way to create a counter that can be used as an index into the string:</p>
<p><code style="color: silver; background: black"><br />
C:\&gt;help set<br />
Displays, sets, or removes cmd.exe environment variables.<br />
&nbsp;<br />
&lt;snip&gt;<br />
Two new switches have been added to the SET command:<br />
&nbsp;<br />
    SET /A expression<br />
    SET /P variable=[promptString]<br />
&nbsp;<br />
The /A switch specifies that the string to the right of the equal sign<br />
is a numerical expression that is evaluated.  The expression evaluator<br />
is pretty simple and supports the following operations, in decreasing<br />
order of precedence:<br />
&nbsp;<br />
    ()                  - grouping<br />
    ! ~ -               - unary operators<br />
    * / %               - arithmetic operators<br />
    + -                 - arithmetic operators<br />
    &lt;&lt; &gt;&gt;               - logical shift<br />
    &amp;                   - bitwise and<br />
    ^                   - bitwise exclusive or<br />
    |                   - bitwise or<br />
    = *= /= %= += -=    - assignment<br />
      &amp;= ^= |= &lt;&lt;= &gt;&gt;=<br />
    ,                   - expression separator<br />
&nbsp;<br />
&lt;snip&gt;<br />
May also specify substrings for an expansion.<br />
&nbsp;<br />
    %PATH:~10,5%<br />
&nbsp;<br />
would expand the PATH environment variable, and then use only the 5<br />
characters that begin at the 11th (offset 10) character of the expanded<br />
result.  If the length is not specified, then it defaults to the<br />
remainder of the variable value.  If either number (offset or length) is<br />
negative, then the number used is the length of the environment variable<br />
value added to the offset or length specified.<br />
&lt;snip&gt;<br />
&nbsp;<br />
</code></p>
<p>In &#8220;help cmd&#8221; we can read about delayed environment variable expansion, which can be used to read/write environment variables at runtime:</p>
<p><code style="color: silver; background: black"><br />
C:\&gt;help cmd<br />
Starts a new instance of the Windows command interpreter<br />
&nbsp;<br />
&lt;snip&gt;<br />
/V:ON   Enable delayed environment variable expansion using ! as the<br />
        delimiter. For example, /V:ON would allow !var! to expand the<br />
        variable var at execution time.  The var syntax expands variables<br />
        at input time, which is quite a different thing when inside of a FOR<br />
        loop.<br />
&lt;snip&gt;<br />
&nbsp;<br />
</code></p>
<p>And in &#8220;help setlocal&#8221; we can find that it is possible to enable delayed environment variable expansion without having to restart cmd.exe:</p>
<p><code style="color: silver; background: black"><br />
C:\&gt;help setlocal<br />
&lt;snip&gt;<br />
        ENABLEDELAYEDEXPANSION / DISABLEDELAYEDEXPANSION<br />
            enable or disable delayed environment variable<br />
            expansion. These arguments takes precedence over the CMD<br />
            /V:ON or /V:OFF switches. See CMD /? for details.<br />
&nbsp;<br />
These modifications last until the matching ENDLOCAL command,<br />
regardless of their setting prior to the SETLOCAL command.<br />
&lt;snip&gt;<br />
&nbsp;<br />
</code></p>
<p>By combing these features, we can create a batch script &#8220;function&#8221; that parses the command line character by character, taking into consideration quotes, equal signs, semicolons, etc&#8230; and creating an environment variable for each argument, in quoted, unquoted and original form, as well as an environment variable that contains the number of arguments:</p>
<p><code><br />
&#x3a;PARSE_ARGV<br />
  SET PARSE_ARGV_ARG=[]<br />
  SET PARSE_ARGV_END=FALSE<br />
  SET PARSE_ARGV_INSIDE_QUOTES=FALSE<br />
  SET /A ARGC = 0<br />
  SET /A PARSE_ARGV_INDEX=1<br />
  &#x3a;PARSE_ARGV_LOOP<br />
  CALL &#x3a;PARSE_ARGV_CHAR !PARSE_ARGV_INDEX! "%%ARGV&#x3a;~!PARSE_ARGV_INDEX!,1%%"<br />
  IF ERRORLEVEL 1 (<br />
    EXIT /B 1<br />
  )<br />
  IF !PARSE_ARGV_END! == TRUE (<br />
    EXIT /B 0<br />
  )<br />
  SET /A PARSE_ARGV_INDEX=!PARSE_ARGV_INDEX! + 1<br />
  GOTO &#x3a;PARSE_ARGV_LOOP<br />
&nbsp;<br />
  &#x3a;PARSE_ARGV_CHAR<br />
    IF ^%~2 == ^" (<br />
      SET PARSE_ARGV_END=FALSE<br />
      SET PARSE_ARGV_ARG=.%PARSE_ARGV_ARG&#x3a;~1,-1%%~2.<br />
      IF !PARSE_ARGV_INSIDE_QUOTES! == TRUE (<br />
        SET PARSE_ARGV_INSIDE_QUOTES=FALSE<br />
      ) ELSE (<br />
        SET PARSE_ARGV_INSIDE_QUOTES=TRUE<br />
      )<br />
      EXIT /B 0<br />
    )<br />
    IF %2 == "" (<br />
      IF !PARSE_ARGV_INSIDE_QUOTES! == TRUE (<br />
        EXIT /B 1<br />
      )<br />
      SET PARSE_ARGV_END=TRUE<br />
    ) ELSE IF NOT "%~2!PARSE_ARGV_INSIDE_QUOTES!" == " FALSE" (<br />
      SET PARSE_ARGV_ARG=[%PARSE_ARGV_ARG&#x3a;~1,-1%%~2]<br />
      EXIT /B 0<br />
    )<br />
    IF NOT !PARSE_ARGV_INDEX! == 1 (<br />
      SET /A ARGC = !ARGC! + 1<br />
      SET ARG!ARGC!=%PARSE_ARGV_ARG&#x3a;~1,-1%<br />
      IF ^%PARSE_ARGV_ARG&#x3a;~1,1% == ^" (<br />
        SET ARG!ARGC!_=%PARSE_ARGV_ARG&#x3a;~2,-2%<br />
        SET ARG!ARGC!Q=%PARSE_ARGV_ARG&#x3a;~1,-1%<br />
      ) ELSE (<br />
        SET ARG!ARGC!_=%PARSE_ARGV_ARG&#x3a;~1,-1%<br />
        SET ARG!ARGC!Q="%PARSE_ARGV_ARG&#x3a;~1,-1%"<br />
      )<br />
      SET PARSE_ARGV_ARG=[]<br />
      SET PARSE_ARGV_INSIDE_QUOTES=FALSE<br />
    )<br />
    EXIT /B 0<br />
&nbsp;<br />
</code></p>
<p>To use it in a batch script, you should add the code to the end of the script and call it at the start like so:</p>
<p><code><br />
@ECHO OFF<br />
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION<br />
&nbsp;<br />
SET ARGV=.%*<br />
CALL &#x3a;PARSE_ARGV<br />
IF ERRORLEVEL 1 (<br />
  ECHO Cannot parse arguments<br />
  ENDLOCAL<br />
  EXIT /B 1<br />
)<br />
&nbsp;<br />
<em>REM Main code goes here</em><br />
ENDLOCAL<br />
EXIT /B 0<br />
&nbsp;<br />
&#x3a;PARSE_ARGV<br />
&lt;snip&gt;<br />
&nbsp;<br />
</code><br />
Note: you should make sure your main code does not &#8220;fall through&#8221; into the PARSE_ARGV function by using &#8220;EXIT /B 0&#8243; at the end of your code.</p>
<p>For each argument passed to the script, numbered environment variables will be created to store the arguments value &#8220;as is&#8221; and in quoted and unquoted form. Additionally, an environment variable will be created that contains the number of arguments supplied. Here is a list of the created environment variables and what they contain:</p>
<ul>
<li>!ARGC! &#8211; Contains the number of arguments,</li>
<li>!ARGx! &#8211; Contains the value of the x-th argument as is,</li>
<li>!ARGx_! &#8211; Contains the value of the x-th argument with any quotes removed,</li>
<li>!ARGxQ! &#8211; Contains the value of the x-th argument with quotes added if not already present,</li>
</ul>
<p>For example: the values for the first argument will be stored in !ARG1!, !ARG1_! and !ARG1Q!.</p>
<p>To make it easier to access any argument(s) by number, the following functions can be used:</p>
<p>To read the values of !ARGx!, !ARGx_! and !ARGxQ! for argument number x into environment variables !y!, !y_! and !yQ! use the below code and &#8220;CALL :GETARG x y&#8221;:</p>
<p><code><br />
&#x3a;GETARG<br />
  SET %2=!ARG%1!<br />
  SET %2_=!ARG%1_!<br />
  SET %2Q=!ARG%1Q!<br />
  EXIT /B 0<br />
&nbsp;<br />
</code><br />
eg. &#8220;CALL :GETARG 1 FIRST_ARGUMENT&#8221; will set !FIRST_ARGUMENT!, !FIRST_ARGUMENT_! and !FIRST_ARGUMENTQ! to the values of !ARG1!, !ARG1_! and !ARG1Q! respectively.</p>
<p>To read the values of the numbered arguments x-y into environment variable !z! use the below code and &#8220;CALL :GETARGS x y z&#8221;:<br />
<code><br />
&#x3a;GETARGS<br />
  SET %3=<br />
  FOR /L %%I IN (%1,1,%2) DO (<br />
    IF %%I == %1 (<br />
      SET %3=!ARG%%I!<br />
    ) ELSE (<br />
      SET %3=!%3! !ARG%%I!<br />
    )<br />
  )<br />
  EXIT /B 0<br />
&nbsp;<br />
</code><br />
eg. &#8220;CALL :GETARGS 1 3 FIRST_THREE_ARGUMENT&#8221; will set !FIRST_THREE_ARGUMENTS! to the values of !ARG1!, !ARG2! and !ARG3! concatinated.</p>
<p>To conclude this post, here is an example that shows how you can use these functions to create a script that parses the command-line arguments correctly and greatly simplifies the handling of a variable number of arguments:</p>
<p><code><br />
@ECHO OFF<br />
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION<br />
&nbsp;<br />
SET ARGV=.%*<br />
CALL &#x3a;PARSE_ARGV<br />
IF ERRORLEVEL 1 (<br />
  ECHO Cannot parse arguments<br />
  ENDLOCAL<br />
  EXIT /B 1<br />
)<br />
&nbsp;<br />
ECHO Arguments count = !ARGC!<br />
FOR /L %%I IN (1,1,!ARGC!) DO (<br />
  CALL &#x3a;GETARG %%I ARGI<br />
  ECHO Argument #%%I = [ !ARGI! ]<br />
)<br />
CALL &#x3a;GETARGS 1 !ARGC! ARGS<br />
ECHO Arguments   = [ !ARGS! ]<br />
&nbsp;<br />
ENDLOCAL<br />
EXIT /B 0<br />
&nbsp;<br />
&#x3a;GETARG<br />
  &lt;snip&gt;<br />
&nbsp;<br />
&#x3a;GETARGS<br />
  &lt;snip&gt;<br />
&nbsp;<br />
&#x3a;PARSE_ARGV<br />
  &lt;snip&gt;<br />
&nbsp;<br />
</code></p>
<p>You can download the example <a href="http://skypher.com/SkyLined/download/batch_command_line_arguments/test.cmd">here</a>. If put the output of this code for the initial test case and various numbers of arguments below:</p>
<p><code style="color:silver; background:black;"><br />
C:\&gt;test.cmd 1=not2;not3 " 2 " 3 4<br />
Arguments count = 4<br />
Argument #1 = [ 1=not2;not3 ]<br />
Argument #2 = [ " 2 " ]<br />
Argument #3 = [ 3 ]<br />
Argument #4 = [ 4 ]<br />
Arguments   = [ 1=not2;not3 " 2 " 3 4 ]<br />
&nbsp;<br />
C:\&gt;test.cmd<br />
Arguments count = 0<br />
Arguments   = [  ]<br />
&nbsp;<br />
C:\&gt;test.cmd 1<br />
Arguments count = 1<br />
Argument #1 = [ 1 ]<br />
Arguments   = [ 1 ]<br />
&nbsp;<br />
C:\&gt;test.cmd 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18<br />
Arguments count = 18<br />
Argument #1 = [ 1 ]<br />
Argument #2 = [ 2 ]<br />
Argument #3 = [ 3 ]<br />
Argument #4 = [ 4 ]<br />
Argument #5 = [ 5 ]<br />
Argument #6 = [ 6 ]<br />
Argument #7 = [ 7 ]<br />
Argument #8 = [ 8 ]<br />
Argument #9 = [ 9 ]<br />
Argument #10 = [ 10 ]<br />
Argument #11 = [ 11 ]<br />
Argument #12 = [ 12 ]<br />
Argument #13 = [ 13 ]<br />
Argument #14 = [ 14 ]<br />
Argument #15 = [ 15 ]<br />
Argument #16 = [ 16 ]<br />
Argument #17 = [ 17 ]<br />
Argument #18 = [ 18 ]<br />
Arguments   = [ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ]<br />
&nbsp;<br />
</code></p>
<p><strong>Limitations/caveats</strong></p>
<ul>
<li>This code depends on the Command Extensions feature as described in &#8220;help cmd&#8221;, if they are disabled and cannot be enabled or are unavailable, the code will not run. As far as I can tell, all versions of Windows since Windows XP at least support the feature and allow it to be enabled if it is disabled, so I do not expect this to be a problem.</li>
<li>This code does not handle unclosed quotes in the arguments. If you execute a test script that uses this code with an unclosed quote in the arguments,as in [test.cmd "], an error message will be shown and the script will not run. Because I do not know of any valid use-case, I expect that this is often caused by an accidentally forgotten closing quote. I assume that the user benefits more from an error that allows him/her to fix the missing quote than from a program that tries to make assumptions about what the user wants.</li>
</ul>
<p>I hope you&#8217;ll find this useful. Please use the comments to let me know if you do or if you have any suggestions!</p>
]]></content:encoded>
			<wfw:commentRss>http://skypher.com/index.php/2010/08/17/batch-command-line-arguments/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Delayed environment variable expansion and command extensions in CMD.EXE</title>
		<link>http://skypher.com/index.php/2009/09/17/delayed-environment-variable-expansion-and-command-extensions-in-cmd-exe/</link>
		<comments>http://skypher.com/index.php/2009/09/17/delayed-environment-variable-expansion-and-command-extensions-in-cmd-exe/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 16:01:16 +0000</pubDate>
		<dc:creator>SkyLined</dc:creator>
				<category><![CDATA[batch scripts]]></category>

		<guid isPermaLink="false">http://skypher.com/?p=201</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  preg_split() [<a href='function.preg-split'>function.preg-split</a>]: Compilation failed: lookbehind assertion is not fixed length at offset 14 in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>77</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>78</b><br />
]]></description>
			<content:encoded><![CDATA[<p>If you want to use delayed environment variable expansion and command extensions in a batch script, here&#8217;s a batch script that functions as a useful cheat sheet for setting, detecting and using them:</p>
<p><CODE>@ECHO OFF<br />
IF &#8220;%1&#8243; == &#8220;TEST_EOF&#8221; (<br />
  GOTO :EOF<br />
) ELSE IF &#8220;%1&#8243; == &#8220;TEST_EXPANSION&#8221; (<br />
  SET extensions=enabled<br />
  IF &#8220;!extensions!&#8221;==&#8221;enabled&#8221; (<br />
    ECHO  Delayed environment variable expansion = ON<br />
  ) ELSE (<br />
    ECHO  Delayed environment variable expansion = OFF<br />
  )<br />
) ELSE IF &#8220;%1&#8243; == &#8220;TEST_EXTENSIONS&#8221; (<br />
  :: CALL :label is not available if test extensions are disabled.<br />
  CALL %0 TEST_EOF 2>nul<br />
  IF NOT ERRORLEVEL 1 (<br />
    ECHO  Command extensions                     = ON<br />
  ) ELSE (<br />
    ECHO  Command extensions                     = OFF<br />
  )<br />
) ELSE (<br />
  ECHO == Default ==<br />
    CALL %0 TEST_EXPANSION<br />
    CALL %0 TEST_EXTENSIONS<br />
  ECHO.<br />
&nbsp;<br />
  ECHO == Enabled ==<br />
    SETLOCAL ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS<br />
    CALL %0 TEST_EXPANSION<br />
    CALL %0 TEST_EXTENSIONS<br />
    ENDLOCAL<br />
  ECHO.<br />
&nbsp;<br />
  ECHO == Disabled ==<br />
    SETLOCAL DISABLEDELAYEDEXPANSION DISABLEEXTENSIONS<br />
    CALL %0 TEST_EXPANSION<br />
    CALL %0 TEST_EXTENSIONS<br />
    ENDLOCAL<br />
)</CODE><br />
(download the script <A href="http://Skypher.com/SkyLined/download/cmd/cmd-env-ext-test.cmd">here</A>).</p>
<p>Here&#8217;s the output of a run on my machine:</p>
<p><CODE>== Default ==<br />
 Delayed environment variable expansion = OFF<br />
 Command extensions                     = ON<br />
&nbsp;<br />
== Enabled ==<br />
 Delayed environment variable expansion = ON<br />
 Command extensions                     = ON<br />
&nbsp;<br />
== Disabled ==<br />
 Delayed environment variable expansion = OFF<br />
 Command extensions                     = OFF<br />
</CODE></p>
]]></content:encoded>
			<wfw:commentRss>http://skypher.com/index.php/2009/09/17/delayed-environment-variable-expansion-and-command-extensions-in-cmd-exe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GNU which for Windows: which.cmd</title>
		<link>http://skypher.com/index.php/2009/09/07/gnu-which-for-windows-which-cmd/</link>
		<comments>http://skypher.com/index.php/2009/09/07/gnu-which-for-windows-which-cmd/#comments</comments>
		<pubDate>Mon, 07 Sep 2009 09:15:15 +0000</pubDate>
		<dc:creator>SkyLined</dc:creator>
				<category><![CDATA[batch scripts]]></category>

		<guid isPermaLink="false">http://skypher.com/?p=181</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  preg_split() [<a href='function.preg-split'>function.preg-split</a>]: Compilation failed: lookbehind assertion is not fixed length at offset 14 in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>77</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>78</b><br />
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve implemented <a href="http://savannah.gnu.org/projects/which">GNU which</a> as a batch script for Windows. GNU which is a utility that is used to find which executable (or alias or shell function) is executed when entered on the shell prompt. Which.cmd does a similar job for windows: it finds which application or script is executed when you execute a command. It works by going through the list of executable extension in the &#8220;%PATHEXT%&#8221; environment variable and then searches through the &#8220;<TT>%PATH%</TT>&#8221; environment variable for a file with the name you provide on the command line for each extension. When it finds a match, it is displayed, when it finds nothing, it reports an error.</p>
<p>Example:<br />
<CODE><br />
C:\>which explorer<br />
C:\Windows\explorer.exe<br />
&nbsp;<br />
C:\>which cmd.exe<br />
C:\Windows\System32\cmd.exe<br />
&nbsp;<br />
C:\>which nc<br />
C:\Tools\nc.exe<br />
&nbsp;<br />
C:\>which blablablabla<br />
&#8220;blablablabla&#8221; not found<br />
&nbsp;<br />
</CODE></p>
<p>You can download the batch script <a href="http://skypher.com/SkyLined/download/GNU%20which/which.cmd">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://skypher.com/index.php/2009/09/07/gnu-which-for-windows-which-cmd/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>BATCH &amp; Python Chimera code</title>
		<link>http://skypher.com/index.php/2009/02/19/batch-python-chimera-code/</link>
		<comments>http://skypher.com/index.php/2009/02/19/batch-python-chimera-code/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 15:12:09 +0000</pubDate>
		<dc:creator>SkyLined</dc:creator>
				<category><![CDATA[batch scripts]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Chimera batch python]]></category>

		<guid isPermaLink="false">http://skypher.com/?p=107</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  preg_split() [<a href='function.preg-split'>function.preg-split</a>]: Compilation failed: lookbehind assertion is not fixed length at offset 14 in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>77</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>78</b><br />
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve create an example of how to create a file that can be run both as a valid cmd.exe batch script as well as a valid Python script. This would be useful if python.exe is available on a system but not set up to handle .py files: a .cmd file can be used to automatically find the python exe and run the script.</p>
<p>The example can be found <a href="http://skypher.com/wiki/index.php?title=Chimera_code">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://skypher.com/index.php/2009/02/19/batch-python-chimera-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fuzzing Opera browser: how to get rid of the &#8220;start-up dialog&#8221; after a crash</title>
		<link>http://skypher.com/index.php/2008/10/23/fuzzing-opera-browser-how-to-get-rid-of-the-start-up-dialog-after-a-crash/</link>
		<comments>http://skypher.com/index.php/2008/10/23/fuzzing-opera-browser-how-to-get-rid-of-the-start-up-dialog-after-a-crash/#comments</comments>
		<pubDate>Thu, 23 Oct 2008 15:50:19 +0000</pubDate>
		<dc:creator>SkyLined</dc:creator>
				<category><![CDATA[batch scripts]]></category>
		<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Opera]]></category>
		<category><![CDATA[Opera Fuzzing Chimera]]></category>

		<guid isPermaLink="false">http://skypher.com/?p=61</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  preg_split() [<a href='function.preg-split'>function.preg-split</a>]: Compilation failed: lookbehind assertion is not fixed length at offset 14 in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>77</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>78</b><br />
]]></description>
			<content:encoded><![CDATA[<p>If you want to automate running Opera to run fuzzers, you&#8217;ll find that once you&#8217;ve crashed Opera, it does not start as normal the next time you run it. Opera had provided a &#8220;<a title="Opera start-up dialog help" href="http://help.opera.com/Windows/9.60/en/dialogs.html#startup" target="_blank">start-up dialog</a>&#8221; for your convenience that shows up after you&#8217;ve crashed it. Also, Opera has a session restore feature that can cause problems when you start Opera using the command-line to open a URL; it will open the pages from the previous session as well. Unfortunately, I was unable to find configuration settings to disabled either one of these features. </p>
<p>To get around these problems I&#8217;ve created a program that will modify the &#8220;Opera.ini&#8221; file as well as delete the session folder. If you run this program, it will remove all traces of a crash that cause Opera to open the start-up dialog and restore the previous session. After running it, you can start Opera as usual.</p>
<p>On the off chance that you&#8217;ve encountered this problem, I&#8217;ve made the program available <a title="Download dirtyOperaHack.zip" href="http://skypher.com/SkyLined/download/Opera/dirtyOperaHack.zip" target="_self">here</a>. The program is called &#8220;dirtyOperaHack.cmd&#8221;. It is a <a title="Skypher wiki on Chimera files" href="http://skypher.com/wiki/index.php?title=Chimera_code#BATCH_script_.26_JavaScript" target="_blank">chimera file</a>; part JavaScript, part batch-file. I&#8217;ve also included the individual source files from which it was created for your convenience. You can run &#8220;make.cmd&#8221; to create &#8221;dirtyOperaHack.cmd&#8221; from the individual source files.</p>
<p><B>UPDATE</B><br />
Opera 10 seems to have changed the paths for some of these settings. I have an updated version of my &#8220;Dirty Opera Hack&#8221; script available <A href="http://skypher.com/SkyLined/download/Opera/dirtyOperaHack2.zip" target="_self">here</A>.</p>
]]></content:encoded>
			<wfw:commentRss>http://skypher.com/index.php/2008/10/23/fuzzing-opera-browser-how-to-get-rid-of-the-start-up-dialog-after-a-crash/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

