<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Silly batch file tricks, redirecting stdout into an evironment variable and %~dp0</title><link>http://weblogs.asp.net/lorenh/archive/2006/03/24/silly-batch-file-tricks-redirecting-stdout-into-an-evironment-variable-and-dp0.aspx</link><description>Some things in batch files seem like they should be so simple, but I'm embarrassed to say how long it took to come up with this little trick. Maybe YOU knew it already, but you should have posted it in your blog so I could have googled it and been done</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>re: Silly batch file tricks, redirecting stdout into an evironment variable and %~dp0</title><link>http://weblogs.asp.net/lorenh/archive/2006/03/24/silly-batch-file-tricks-redirecting-stdout-into-an-evironment-variable-and-dp0.aspx#7269903</link><pubDate>Thu, 03 Dec 2009 21:27:23 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7269903</guid><dc:creator>Sen2008</dc:creator><author>Sen2008</author><description>&lt;p&gt;Nice dialog going on here.&lt;/p&gt;
&lt;p&gt;Someone mentioned pipes. I use biterscripting ( &lt;a rel="nofollow" target="_new" href="http://www.biterscripting.com"&gt;http://www.biterscripting.com&lt;/a&gt; ) for implementing pipes.&lt;/p&gt;
&lt;p&gt;A pipe is a data connection between two commands. There can be four types of pipes. I will show an example of how I do this.&lt;/p&gt;
&lt;p&gt;THE STRAIGHT PIPE&lt;/p&gt;
&lt;p&gt;Output of one command goes into input of another command.&lt;/p&gt;
&lt;p&gt;# Code&lt;/p&gt;
&lt;p&gt;lf &amp;gt; $s&lt;/p&gt;
&lt;p&gt;len $s&lt;/p&gt;
&lt;p&gt;# End code&lt;/p&gt;
&lt;p&gt;THE TEE (T) PIPE&lt;/p&gt;
&lt;p&gt;Output of one command goes into input of two commands.&lt;/p&gt;
&lt;p&gt;# Code&lt;/p&gt;
&lt;p&gt;lf &amp;gt; $s&lt;/p&gt;
&lt;p&gt;len $s&lt;/p&gt;
&lt;p&gt;echo $s&lt;/p&gt;
&lt;p&gt;# End code&lt;/p&gt;
&lt;p&gt;THE WYE (Y) PIPE&lt;/p&gt;
&lt;p&gt;Output of two commands go into input of one command.&lt;/p&gt;
&lt;p&gt;# Code&lt;/p&gt;
&lt;p&gt;cat x.txt &amp;gt; $s&lt;/p&gt;
&lt;p&gt;cat y.txt &amp;gt;&amp;gt; $s&lt;/p&gt;
&lt;p&gt;echo $s&lt;/p&gt;
&lt;p&gt;# End code&lt;/p&gt;
&lt;p&gt;THE EH (H) PPE&lt;/p&gt;
&lt;p&gt;Output of two commands go into input of two commands.&lt;/p&gt;
&lt;p&gt;# Code&lt;/p&gt;
&lt;p&gt;cat x.txt &amp;gt; $s&lt;/p&gt;
&lt;p&gt;cat y.txt &amp;gt;&amp;gt; $s&lt;/p&gt;
&lt;p&gt;len $s&lt;/p&gt;
&lt;p&gt;echo $s&lt;/p&gt;
&lt;p&gt;# End code&lt;/p&gt;
&lt;p&gt;These four types of pipes are also called one-to-one, one-to-many, many-to-one and many-to-many. By using variables, I can implement all four. Pretty clever. But you need a language that allows you to redirect a command's output (and errors) to a variable.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7269903" width="1" height="1"&gt;</description></item><item><title>re: Silly batch file tricks, redirecting stdout into an evironment variable and %~dp0</title><link>http://weblogs.asp.net/lorenh/archive/2006/03/24/silly-batch-file-tricks-redirecting-stdout-into-an-evironment-variable-and-dp0.aspx#7261241</link><pubDate>Fri, 20 Nov 2009 07:23:56 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7261241</guid><dc:creator>Judago</dc:creator><author>Judago</author><description>&lt;p&gt;Here's a little trick that gets the length of a variable, why oh why didn't they add a length parameter when they added substrings....&lt;/p&gt;
&lt;p&gt;for /f %%a in ('cmd /u /c set /p &amp;quot;=%str:&amp;quot;= %&amp;quot;^&amp;lt;nul^|find /v /c &amp;quot;&amp;quot;') do echo %%a&lt;/p&gt;
&lt;p&gt;where %str% is the variable (%str:&amp;quot;= % is to avoid double quote conflicts by converting &amp;quot;'s to spaces)&lt;/p&gt;
&lt;p&gt;Try it without the &amp;quot;/c&amp;quot; switch to the find command ;)&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7261241" width="1" height="1"&gt;</description></item><item><title>re: Silly batch file tricks, redirecting stdout into an evironment variable and %~dp0</title><link>http://weblogs.asp.net/lorenh/archive/2006/03/24/silly-batch-file-tricks-redirecting-stdout-into-an-evironment-variable-and-dp0.aspx#7241846</link><pubDate>Wed, 28 Oct 2009 22:58:22 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7241846</guid><dc:creator>David Gray</dc:creator><author>David Gray</author><description>&lt;p&gt;I may be a tad old fashioned, but I still think batch files have a place. They are lean, reasonably fast, and run without a bunch of extra infrastructure that may be missing or disabled for security reasons. For instance, WSH may be disabled, and neither Perl nor PowerShell is part of a default installation of Windows.&lt;/p&gt;
&lt;p&gt;Paraphrasing a comment that I heard, in a TechEd session long ago, about Notepad, CMD.EXE is everywhere.&lt;/p&gt;
&lt;p&gt;Apart from the one spam message that crept into it, this blog is fabulous. I found it in the course of a Google search, pinned it into my Favorites, and have referred to it several times in the last week or so.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7241846" width="1" height="1"&gt;</description></item><item><title>re: Silly batch file tricks, redirecting stdout into an evironment variable and %~dp0</title><link>http://weblogs.asp.net/lorenh/archive/2006/03/24/silly-batch-file-tricks-redirecting-stdout-into-an-evironment-variable-and-dp0.aspx#7224565</link><pubDate>Wed, 07 Oct 2009 05:21:45 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7224565</guid><dc:creator>Grant Peters</dc:creator><author>Grant Peters</author><description>&lt;p&gt;I'm surprised about all the hacks i saw in the comments to avoid the temp.txt file (such as using the for command). Why not just pipe directly from one into the other, i.e.&lt;/p&gt;
&lt;p&gt;sometool.exe | set /p TOOLOUTPUT=&lt;/p&gt;
&lt;p&gt;and thats it.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7224565" width="1" height="1"&gt;</description></item><item><title>re: Silly batch file tricks, redirecting stdout into an evironment variable and %~dp0</title><link>http://weblogs.asp.net/lorenh/archive/2006/03/24/silly-batch-file-tricks-redirecting-stdout-into-an-evironment-variable-and-dp0.aspx#7220090</link><pubDate>Tue, 29 Sep 2009 19:10:44 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7220090</guid><dc:creator>Aloe Vera Distributor - myflp.org</dc:creator><author>Aloe Vera Distributor - myflp.org</author><description>&lt;p&gt;Hello there.&lt;/p&gt;
&lt;p&gt;I have something to say, about AloeVera, something about which you wrote above, about health and minerals... For a long time, I and my nice friend use the products of the flp. We every time see the good results and also we make money for our families and we are happy. My friend works with Aloe Vera in the company of forever living products has more than 5 years (My friend works ONLY in the flp company and has a wife and three children). I know aloe Vera products for weight loss for a long time, but a year ago, began working as a distributor in the Forever Living Company.&lt;/p&gt;
&lt;p&gt;Of course, this job is some difficult, but in no other case, You can earn so much money with so much much fun and good smiling faces around..&lt;/p&gt;
&lt;p&gt;So if you want to discuss something about which you wrote above, and about my experience with Aloe vera products for weight loss, I'll always be glad to talk. &lt;/p&gt;
&lt;p&gt;Best regards from Washington state and have a nice day!&lt;/p&gt;
&lt;p&gt;Andrew - Aloe Vera Distributor&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7220090" width="1" height="1"&gt;</description></item><item><title>re: Silly batch file tricks, redirecting stdout into an evironment variable and %~dp0</title><link>http://weblogs.asp.net/lorenh/archive/2006/03/24/silly-batch-file-tricks-redirecting-stdout-into-an-evironment-variable-and-dp0.aspx#7196629</link><pubDate>Tue, 08 Sep 2009 16:58:34 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7196629</guid><dc:creator>Taz</dc:creator><author>Taz</author><description>&lt;p&gt;Or you could simply do:&lt;/p&gt;
&lt;p&gt;cd /d %~dp0&lt;/p&gt;
&lt;p&gt;And it would change both the drive and the current dir.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7196629" width="1" height="1"&gt;</description></item><item><title>re: Silly batch file tricks, redirecting stdout into an evironment variable and %~dp0</title><link>http://weblogs.asp.net/lorenh/archive/2006/03/24/silly-batch-file-tricks-redirecting-stdout-into-an-evironment-variable-and-dp0.aspx#7184790</link><pubDate>Sat, 29 Aug 2009 02:51:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7184790</guid><dc:creator>Eric</dc:creator><author>Eric</author><description>&lt;p&gt;Also of note: %~d0 will give the Drive Letter where the script is located. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;This would be necessary in some cases; for example, if you are running the script from a different drive, you can't simply &amp;quot;cd %~dp0&amp;quot; because you have to switch drives first. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;So you could do this in the batch file:&lt;/p&gt;
&lt;p&gt;%~d0&lt;/p&gt;
&lt;p&gt;cd %~dp0&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7184790" width="1" height="1"&gt;</description></item><item><title>re: Silly batch file tricks, redirecting stdout into an evironment variable and %~dp0</title><link>http://weblogs.asp.net/lorenh/archive/2006/03/24/silly-batch-file-tricks-redirecting-stdout-into-an-evironment-variable-and-dp0.aspx#7046868</link><pubDate>Wed, 15 Apr 2009 12:14:42 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7046868</guid><dc:creator>Maddy</dc:creator><author>Maddy</author><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Can anyone suggest a method by which we can extract the output or the contents of an IDE to a text file.&lt;/p&gt;
&lt;p&gt;A batch file named run.bat calls the IDE under test.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;Maddy&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7046868" width="1" height="1"&gt;</description></item><item><title>re: Silly batch file tricks, redirecting stdout into an evironment variable and %~dp0</title><link>http://weblogs.asp.net/lorenh/archive/2006/03/24/silly-batch-file-tricks-redirecting-stdout-into-an-evironment-variable-and-dp0.aspx#6957095</link><pubDate>Fri, 13 Mar 2009 07:01:03 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6957095</guid><dc:creator>ChernoJ</dc:creator><author>ChernoJ</author><description>&lt;p&gt;Date and Time: Instead of date /t and time /t, there're the built-in %date% and %time% env vars.&lt;/p&gt;
&lt;p&gt;eg:&lt;/p&gt;
&lt;p&gt;echo %time%&lt;/p&gt;
&lt;p&gt;set timestamp=%date% %time%&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6957095" width="1" height="1"&gt;</description></item><item><title>re: Silly batch file tricks, redirecting stdout into an evironment variable and %~dp0</title><link>http://weblogs.asp.net/lorenh/archive/2006/03/24/silly-batch-file-tricks-redirecting-stdout-into-an-evironment-variable-and-dp0.aspx#6936266</link><pubDate>Tue, 03 Mar 2009 14:14:33 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6936266</guid><dc:creator>Timestamp</dc:creator><author>Timestamp</author><description>&lt;p&gt;nice aswel is timestamp environment var to spool to a timestamped batch file&lt;/p&gt;
&lt;p&gt;:: sets the timestamp arguments to the actual date &amp;amp; time&lt;/p&gt;
&lt;p&gt;for /f &amp;quot;tokens=1,2 delims=: &amp;quot; %%i in ('time /t') do set hhmi=%%i%%j&lt;/p&gt;
&lt;p&gt;for /f &amp;quot;tokens=2,3,4 delims=/- &amp;quot; %%i in ('date /t') do set yyyymmdd=%%k%%j%%i&lt;/p&gt;
&lt;p&gt;set log_backup_changes=%yyyymmdd%-%hhmi%_backup.log&lt;/p&gt;
&lt;p&gt;rman target / @%script_backup_changes% log=%log_backup_changes% append&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6936266" width="1" height="1"&gt;</description></item></channel></rss>