<?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>A Programmer with Microsoft tools &#187; quick and dirty</title>
	<atom:link href="http://msprogrammer.serviciipeweb.ro/category/mini-tools-list/quick-and-dirty/feed/" rel="self" type="application/rss+xml" />
	<link>http://msprogrammer.serviciipeweb.ro</link>
	<description>A programmer journey through code, books and tools</description>
	<lastBuildDate>Mon, 14 May 2012 06:59:14 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Transform Mozilla Bookmarks into a list</title>
		<link>http://msprogrammer.serviciipeweb.ro/2011/11/28/transform-mozilla-bookmarks-into-a-list/</link>
		<comments>http://msprogrammer.serviciipeweb.ro/2011/11/28/transform-mozilla-bookmarks-into-a-list/#comments</comments>
		<pubDate>Mon, 28 Nov 2011 05:50:00 +0000</pubDate>
		<dc:creator>Andrei Ignat</dc:creator>
				<category><![CDATA[addons]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[quick and dirty]]></category>

		<guid isPermaLink="false">http://msprogrammer.serviciipeweb.ro/2011/11/28/transform-mozilla-bookmarks-into-a-list/</guid>
		<description><![CDATA[You have seen that I begin to post “friday links”
It is simple , once you have SqlLite Manager add-on for FF. ( add-on, source)
Just run the following query ( for the last 7 days bookmarks) by selecting &#8220;places.sqllite&#8221;:

SELECT
&#34;&#60;p&#62;&#60;a target='_blank' href='&#34; &#124;&#124; moz_places.url  &#124;&#124; &#34;'&#62;&#34; &#124;&#124; moz_bookmarks.title &#124;&#124; &#34;&#60;/a&#62;&#60;/p&#62;&#34;

FROM moz_bookmarks Inner JOIN moz_places WHERE moz_bookmarks.fk [...]]]></description>
			<content:encoded><![CDATA[<p>You have seen that I begin to post “<a href="http://msprogrammer.serviciipeweb.ro/category/friday-links/" target="_blank">friday links</a>”</p>
<p>It is simple , once you have <a href="https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/" target="_blank">SqlLite Manager add-on</a> for FF. ( <a href="https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/" target="_blank">add-on</a>, <a href="http://code.google.com/p/sqlite-manager/" target="_blank">source</a>)</p>
<p>Just run the following query ( for the last 7 days bookmarks) by selecting &#8220;places.sqllite&#8221;:</p>
<pre class="brush: sql;">
SELECT
&quot;&lt;p&gt;&lt;a target='_blank' href='&quot; || moz_places.url  || &quot;'&gt;&quot; || moz_bookmarks.title || &quot;&lt;/a&gt;&lt;/p&gt;&quot;

FROM moz_bookmarks Inner JOIN moz_places WHERE moz_bookmarks.fk = moz_places.id AND moz_bookmarks.title != &quot;null&quot;
and last_visit_date BETWEEN  strftime('%s',date('now','-7 day'))*1000000 and strftime('%s',date('now'))*1000000
and dateAdded BETWEEN  strftime('%s',date('now','-7 day'))*1000000 and strftime('%s',date('now'))*1000000
</pre>
<p>(OK, I must know why I multiply by 1000000  &#8211; but,hey – it works ….)</p>
]]></content:encoded>
			<wfw:commentRss>http://msprogrammer.serviciipeweb.ro/2011/11/28/transform-mozilla-bookmarks-into-a-list/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>LogParser, PowerShell and Quick and dirty parsing of IIS files</title>
		<link>http://msprogrammer.serviciipeweb.ro/2010/09/20/logparser-powershell-and-quick-and-dirty-parsing-of-iis-files/</link>
		<comments>http://msprogrammer.serviciipeweb.ro/2010/09/20/logparser-powershell-and-quick-and-dirty-parsing-of-iis-files/#comments</comments>
		<pubDate>Mon, 20 Sep 2010 04:44:55 +0000</pubDate>
		<dc:creator>Andrei Ignat</dc:creator>
				<category><![CDATA[mini tools list]]></category>
		<category><![CDATA[quick and dirty]]></category>
		<category><![CDATA[logparser]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://msprogrammer.serviciipeweb.ro/?p=430</guid>
		<description><![CDATA[For a local enterprise IIS system you do not have to resort to Google analytics or other beasts that interprets IIs logs. After all, users are identified through ActiveDirectory, does not matter from what city do they come, and so on. But it will help to have some details of wjhat happened on the system [...]]]></description>
			<content:encoded><![CDATA[<p>For a local enterprise IIS system you do not have to resort to Google analytics or other beasts that interprets IIs logs. After all, users are identified through ActiveDirectory, does not matter from what city do they come, and so on. But it will help to have some details of wjhat happened on the system this day( or the day before , if you want to send an email about the previous day totals)</p>
<p>So <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&amp;displaylang=en" target="_blank">logparser</a> to help  &#8211; he knows already to read IIS logs with  -i:IISW3C</p>
<p>So I have come up with the syntax  :</p>
<p><strong>C:\</strong>LogParser -e:10 -i:IISW3C &#8220;SELECT cs-uri-stem as url, DIV(SUM(time-taken),1000) as Seconds, Count(time-taken) as Requests, DIV(Seconds ,Requests) as TimeExecuting   INTO <strong><em>C:\newfile</em></strong> FROM   <strong><em>C:\Windows\System32\LogFiles\W3SVC1\ex100909.log</em></strong> GROUP BY cs-uri-stem Having SUM(time-taken)&gt;0 and Seconds&gt;0 order by Seconds   desc&#8221; -o:TPL -tpl:%2\iistime.tpl</p>
<p>Basically , this will do this report about statuses of URL requested  :</p>
<table border="1" cellpadding="10" bgcolor="#d0d0e0">
<tbody>
<tr>
<th>Status</th>
<th>Requests</th>
</tr>
<tr>
<td><tt>200</tt></td>
<td><tt>1541</tt></td>
</tr>
<tr>
<td><tt>302</tt></td>
<td><tt>89</tt></td>
</tr>
<tr>
<td><tt>401</tt></td>
<td><tt>11</tt></td>
</tr>
<tr>
<td><tt>403</tt></td>
<td><tt>61</tt></td>
</tr>
</tbody>
</table>
<p>The problem is that <strong><em>C:\newfile</em></strong> and  <strong><em>C:\Windows\System32\LogFiles\W3SVC1\ex100909.log</em></strong> are hard-coded – we need to modify every time… So PowerShell to the rescue (Ok, I could do a C# Console program – but</p>
<p>1. it is more fun this way – fun meaning I want to learn something new</p>
<p>2. the script could be modified easily</p>
<p>)</p>
<p>So the same command is written this way with arguments , in order to can be executed each time :</p>
<pre class="brush: csharp;">
%2\LogParser -e:10 -i:IISW3C &quot;SELECT cs-uri-stem as url, DIV(SUM(time-taken),1000) as Seconds, Count(time-taken) as Requests, DIV(Seconds ,Requests) as TimeExecuting   INTO %2\%4 FROM   %5\*%1  GROUP BY cs-uri-stem Having SUM(time-taken)&amp;gt;0 and Seconds&amp;gt;0 order by Seconds   desc&quot; -o:TPL -tpl:%2\iistime.tpl
</pre>
<p>But who will give arguments ( such as the system date ) ?Now powershell  to the rescue :</p>
<pre class="brush: csharp;">
$namepc = (gc env:computername)
$a = get-date
$a = (get-date).AddDays(-1)
$allpath= Split-Path -Parent $MyInvocation.MyCommand.Path;
$logfolders = $env:WINDIR +&quot;\system32\Logfiles\W3SVC*&quot;
foreach($logfolder in  Get-ChildItem $logfolders)
{
$logfiles= $logfolder.FullName
Write-Host &quot;parsing&quot;  $logfiles
$log =  $a.ToString(&quot;yyMMdd&quot;) + &quot;.log&quot;
$process = [Diagnostics.Process]::Start($allpath + &quot;\iis.bat&quot; , $log + &quot; &quot;+ $allpath + &quot; &quot;+ $log + &quot;.html&quot; + &quot; TIME&quot; +$log + &quot;.html&quot; + &quot; &quot; + $logfiles)
$process.WaitForExit()
$content = &quot;&amp;lt;h1&amp;gt;IIS REPORT &quot; + $namepc  + &quot;&amp;lt;/H1&amp;gt;&quot;
$content += (get-content ($allpath  + &quot;\&quot; + $log + &quot;.html&quot;))
$content += (get-content ($allpath  + &quot;\TIME&quot; + $log + &quot;.html&quot;))

$SmtpClient = new-object system.net.mail.smtpClient
$SmtpServer = &quot;your server&quot;
$SmtpClient.host = $SmtpServer

$mm = new-Object System.Net.Mail.MailMessage(“&lt;a href=&quot;mailto:from@yourcompany.com&quot;&gt;from@yourcompany.com&lt;/a&gt;”,&quot;&lt;a href=&quot;mailto:to@yourcompany.com&quot;&gt;to@yourcompany.com&lt;/a&gt;&quot;)
$mm.Subject = &quot;Report IIS &quot; + $namepc
$mm.Body = $content
$mm.Body=$mm.Body.Replace(&quot;&amp;lt;cmp&amp;gt;&quot;,$namepc  )
$mm.IsBodyHtml = 1
$SmtpClient.Send($mm)
}
</pre>
<p>Explanation of code :<br />
line 1: I take the computer name to put in the report<br />
line 2 : take the date ( if you want the current date , just comment the line 3)<br />
line 5 : I go to usual path to logfiles (did I say quick and dirty ?)<br />
line 6 : get all W3SVC folders and iterate to send report<br />
line 11 : launching the bat (that contains logparser command ) in order to parse  arguments<br />
line 12 :waiting for the process to exit &#8211; in order to can send files.<br />
line 13 to 15: get the output<br />
line 17 to 27 : send the output by email</p>
<p>Homework  :<br />
1. Execute script on a system and modify if it does not work<br />
2. Clean up the temporary files after sending email<br />
3. Instead of sending an email, write into a database with the current date.</p>
<p>You can execute sc.bat at regular times ( such as 1:00 AM)</p>
<p>Here is the zip file with sources <a href="http://msprogrammer.serviciipeweb.ro/wp-content/uploads/2010/09/logiisparser.zip">logiisparser</a></p>
<p>LogParser download : <a title="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&amp;displaylang=en" href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&amp;displaylang=en">http://www.microsoft.com/downloads/en/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&amp;displaylang=en</a></p>
<p>Powershell scripts : <a title="http://gallery.technet.microsoft.com/ScriptCenter/en-us/site/search?f[1].Type=SearchText&amp;f[1].Value=internet&amp;f[0].Value=applications&amp;f[0].Type=RootCategory&amp;f[0].Text=Applications&amp;x=0&amp;y=0" href="http://gallery.technet.microsoft.com/ScriptCenter/en-us/site/search?f[1].Type=SearchText&amp;f[1].Value=internet&amp;f[0].Value=applications&amp;f[0].Type=RootCategory&amp;f[0].Text=Applications&amp;x=0&amp;y=0">http://gallery.technet.microsoft.com/ScriptCenter/en-us/site/search?f[1].Type=SearchText&amp;f[1].Value=internet&amp;f[0].Value=applications&amp;f[0].Type=RootCategory&amp;f[0].Text=Applications&amp;x=0&amp;y=0</a></p>
]]></content:encoded>
			<wfw:commentRss>http://msprogrammer.serviciipeweb.ro/2010/09/20/logparser-powershell-and-quick-and-dirty-parsing-of-iis-files/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Logparser quick and dirty</title>
		<link>http://msprogrammer.serviciipeweb.ro/2010/09/13/logparser-quick-and-dirty/</link>
		<comments>http://msprogrammer.serviciipeweb.ro/2010/09/13/logparser-quick-and-dirty/#comments</comments>
		<pubDate>Mon, 13 Sep 2010 05:10:15 +0000</pubDate>
		<dc:creator>Andrei Ignat</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[mini tools list]]></category>
		<category><![CDATA[quick and dirty]]></category>
		<category><![CDATA[logparser]]></category>

		<guid isPermaLink="false">http://msprogrammer.serviciipeweb.ro/?p=427</guid>
		<description><![CDATA[Sometimes you must find information in text files. Many,many text files, like IIS logs or other custom non-regular formats.
I have a bot from http://www.imified.com/ – and I log the messages with log4net in text files, with another messages.
An entry looks like that :
System.ArgumentException: ;channel=private;botkey=&#60;guid&#62;;userkey=&#60;guid&#62;;user=name@yhaoo.com;network=Yahoo;msg=hello;step=1;value0=hello;to=asdasd
And there are multiple log files that I want to parse and [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes you must find information in text files. Many,many text files, like IIS logs or other custom non-regular formats.</p>
<p>I have a <a href="ymsgr:sendim?cursval&amp;m=bnr+eur" target="_blank">bot</a> from <a title="http://www.imified.com/" href="http://www.imified.com/">http://www.imified.com/</a> – and I log the messages with <a href="http://logging.apache.org/log4net/" target="_blank">log4net</a> in text files, with another messages.</p>
<p>An entry looks like that :</p>
<p>System.ArgumentException: ;channel=private;botkey=&lt;guid&gt;;userkey=&lt;guid&gt;;user=name@yhaoo.com;network=Yahoo;msg=hello;step=1;value0=hello;to=asdasd</p>
<p>And there are multiple log files that I want to parse and find the email adresses to collect feedback from those persons that use my bot.</p>
<p><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&amp;displaylang=en" target="_blank">LogParser</a> to the rescue! Download from <a title="http://www.microsoft.com/downloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&amp;displaylang=en" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&amp;displaylang=en">http://www.microsoft.com/downloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&amp;displaylang=en</a> and use this command line</p>
<p>LOGPARSER &#8220;Select Text into a.csv from current* where Text like &#8216;%@%&#8217;&#8221; -i:TEXTLINE</p>
<p>Explanation of command :</p>
<p>Select Text into a.csv from current* where Text like &#8216;%@%&#8217; –means find in files that begin with current(current*) all text that contains emails ( ‘%@%’) and put in file a.csv  the results.</p>
<p>-i:TEXTLINE – means the format is text</p>
<p>What can be more simple ?</p>
<p>(Ok, for finding the user name I had to resort to excel, to remove duplicates … )</p>
<p>More I think it is fast enough : for parsing 114 files with 58.8 MB (PC with a 2GB RAM + 7200 RPM ) the results are :</p>
<p>Statistics:<br />
&#8212;&#8212;&#8212;&#8211;<br />
Elements processed: 487176<br />
Elements output:    1044<br />
Execution time:     7.69 seconds</p>
<p>Also logparser can be used for more than text files :</p>
<p><a title="http://support.microsoft.com/kb/910447" href="http://support.microsoft.com/kb/910447">http://support.microsoft.com/kb/910447</a></p>
<p><a title="http://www.stevebunting.org/udpd4n6/forensics/logparser.htm" href="http://www.stevebunting.org/udpd4n6/forensics/logparser.htm">http://www.stevebunting.org/udpd4n6/forensics/logparser.htm</a></p>
<p>More, it can be as a COM DLL in every .NET project, making it a usefull tool . See</p>
<p><a title="http://www.codeproject.com/KB/recipes/SimpleLogParse.aspx" href="http://www.codeproject.com/KB/recipes/SimpleLogParse.aspx">http://www.codeproject.com/KB/recipes/SimpleLogParse.aspx</a></p>
<p>Next time I will show the using Powershell in combination with <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&amp;displaylang=en" target="_blank">LogParser</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://msprogrammer.serviciipeweb.ro/2010/09/13/logparser-quick-and-dirty/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

