<?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>my personal scripting hell</title>
	<atom:link href="http://blog.artworkz.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.artworkz.net</link>
	<description></description>
	<lastBuildDate>Sun, 12 Feb 2012 23:03:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>fill PDF forms with powershell</title>
		<link>http://blog.artworkz.net/2012/02/12/fill-pdf-forms-with-powershell/</link>
		<comments>http://blog.artworkz.net/2012/02/12/fill-pdf-forms-with-powershell/#comments</comments>
		<pubDate>Sun, 12 Feb 2012 22:57:59 +0000</pubDate>
		<dc:creator>mathse</dc:creator>
				<category><![CDATA[scripting]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://blog.artworkz.net/?p=29</guid>
		<description><![CDATA[there are some tutorials on how to create pdf files with powershell like this one here: http://www.powershell.nu/2009/09/08/scripting-pdf-documents-through-powershell/ i had some troubles to open and change an already created pdf &#8211; here is how it needs to be done # load the &#8230; <a href="http://blog.artworkz.net/2012/02/12/fill-pdf-forms-with-powershell/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>there are some tutorials on how to create pdf files with powershell like this one here: http://www.powershell.nu/2009/09/08/scripting-pdf-documents-through-powershell/</p>
<p>i had some troubles to open and change an already created pdf &#8211; here is how it needs to be done</p>
<pre class="wp-code-highlight prettyprint"># load the pdf library
[System.Reflection.Assembly]::LoadFrom(&quot;itextsharp.dll&quot;) 

# read the form
$reader = New-Object iTextSharp.text.pdf.pdfreader -ArgumentList &quot;form.pdf&quot; 

# create a new file with the read content
$writer = New-Object iTextSharp.text.pdf.pdfstamper($reader, [System.IO.File]::Create(&quot;filled-form.pdf&quot;)) 

# set content to a form field
$writer.AcroFields.SetField('key','value') 

# close the filestream
$writer.Close() </pre>
<p>this will work for unencrypted pdf files</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.artworkz.net/2012/02/12/fill-pdf-forms-with-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>delete comments on nagios hosts/services which are not critical anymore</title>
		<link>http://blog.artworkz.net/2011/12/28/delete-comments-on-nagios-hostsservices-which-are-not-critical-anymore/</link>
		<comments>http://blog.artworkz.net/2011/12/28/delete-comments-on-nagios-hostsservices-which-are-not-critical-anymore/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 15:32:25 +0000</pubDate>
		<dc:creator>mathse</dc:creator>
				<category><![CDATA[scripting]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[Nagios]]></category>

		<guid isPermaLink="false">http://blog.artworkz.net/?p=23</guid>
		<description><![CDATA[As i googled around and hadnt found anything for Nagios 3.x i decided to write that script myself. It will only delete the comments of checks which are okay again since Nagios is not taking care of that. #!/bin/bash # &#8230; <a href="http://blog.artworkz.net/2011/12/28/delete-comments-on-nagios-hostsservices-which-are-not-critical-anymore/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>As i googled around and hadnt found anything for Nagios 3.x i decided to write that script myself. It will only delete the comments of checks which are okay again since Nagios is not taking care of that.</p>
<pre class="wp-code-highlight prettyprint">#!/bin/bash
# Deletes comments from host and services no longer in critical status. Developed for Nagios 3.x
# Author: Mathias Decker, &lt;mathias@itgweb.de&gt;
# Date: 27/12/2011

# Global Vars
NAGIOS_CMD='/var/nagios/rw/nagios.cmd'
LOG='/var/nagios/status.dat'

# Remove no longer used service comments
# explanation: convert blanks -&gt; get all comments and 3 lines up -&gt; get rid of tabs -&gt; make 1 line not for -&gt; skip the other 'blocks'
for c in $(cat $LOG | sed 's/ /+blank+/g' | grep -B3 &quot;^ comment_id=&quot; | sed 's/	//g' | sed ':a;N;$!ba;s/\n/;/g' | sed 's/--/\n/g')
do
        comment_id=$(echo $c | sed 's/;/\n/g' | grep &quot;^comment_id&quot; | sed 's/comment_id=//g')
        host_name=$(echo $c | sed 's/;/\n/g' | grep host_name | sed 's/host_name=//g')
        service_name=$(echo $c | sed 's/;/\n/g' | grep service_description | sed 's/service_description=//g')

        if [ ! -z $service_name ]
        then
                service_name=$(echo $service_name | sed 's/+blank+/ /g') #get back the blanks
                host_name=$(echo $host_name | sed 's/+blank+/ /g')
                state=$(cat $LOG | grep -B15 current_state | grep &quot;$host_name$&quot; -A14 | grep &quot;=$service_name$&quot; -A13 | grep &quot;current_state=&quot; | sed 's/	current_state=//g') # theres a tab in front of current_state
                # get all services which got state=0 which is okay
                if [ $state = 0 ]
                then
#                       echo &quot;$host_name - $service_name - $comment_id - '$state'&quot; # uncomment for debugging
                        NOW='date +%s'
                        echo &quot;[$NOW] DEL_SVC_COMMENT;$comment_id;$NOW&quot; &gt;&gt; $NAGIOS_CMD # this will get rid of the comment
                fi
        fi
done

#remove no longer used host comments
for c in $(cat $LOG | sed 's/ /+blank+/g' | grep -A3 &quot;hostcomment&quot; | sed 's/	//g' | sed ':a;N;$!ba;s/\n/;/g' | sed 's/--/\n/g')
do
        comment_id=$(echo $c | sed 's/;/\n/g' | grep &quot;^comment_id&quot; | sed 's/comment_id=//g')
        host_name=$(echo $c | sed 's/;/\n/g' | grep host_name | sed 's/host_name=//g')
        if [ ! -z $host_name ]
        then
                host_name=$(echo $host_name | sed 's/+blank+/ /g')
                state=$(cat $LOG | grep -B15 current_state | grep &quot;$host_name$&quot; -A14 -B1 | grep &quot;hoststatus&quot; -A14 | grep &quot;current_state=&quot; | sed 's/	current_state=//g')
                if [ $state = 0 ]
                then
#                       echo &quot;$host_name - $comment_id - $state&quot;
                        NOW='date +%s'
                        echo &quot;[$NOW] DEL_HOST_COMMENT;$comment_id;$NOW&quot; &gt;&gt; $NAGIOS_CMD
                fi
        fi
done
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.artworkz.net/2011/12/28/delete-comments-on-nagios-hostsservices-which-are-not-critical-anymore/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>resize images in a single line</title>
		<link>http://blog.artworkz.net/2011/11/27/resize-images-in-a-single-line/</link>
		<comments>http://blog.artworkz.net/2011/11/27/resize-images-in-a-single-line/#comments</comments>
		<pubDate>Sun, 27 Nov 2011 09:51:22 +0000</pubDate>
		<dc:creator>mathse</dc:creator>
				<category><![CDATA[scripting]]></category>
		<category><![CDATA[bash]]></category>

		<guid isPermaLink="false">http://blog.artworkz.net/?p=13</guid>
		<description><![CDATA[you got a bunch of photos you wanna resize in width and height &#8230; lets say 800px will be enough. Fire up a shell, cd in the directory where your photos stored. for i in $(ls -1 *.jpg &#124; sed &#8230; <a href="http://blog.artworkz.net/2011/11/27/resize-images-in-a-single-line/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>you got a bunch of photos you wanna resize in width and height &#8230; lets say 800px will be enough. Fire up a shell, cd in the directory where your photos stored.</p>
<pre class="wp-code-highlight prettyprint">for i in $(ls -1 *.jpg | sed 's/ /;/g'); do
   convert -resize 800x800 &quot;$(echo $i | sed 's/;/ /g')&quot; &quot;/path/to/destiantion/$(echo $i | sed 's/;/ /g')&quot;
done</pre>
<p>The &#8220;sed &#8216;s/ /;/g&#8217;&#8221; is to handle filenames with a blank.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.artworkz.net/2011/11/27/resize-images-in-a-single-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>get a progress bar for dd</title>
		<link>http://blog.artworkz.net/2011/11/26/get-a-progress-bar-for-dd/</link>
		<comments>http://blog.artworkz.net/2011/11/26/get-a-progress-bar-for-dd/#comments</comments>
		<pubDate>Sat, 26 Nov 2011 15:45:03 +0000</pubDate>
		<dc:creator>mathse</dc:creator>
				<category><![CDATA[scripting]]></category>
		<category><![CDATA[bash]]></category>

		<guid isPermaLink="false">http://blog.artworkz.net/?p=11</guid>
		<description><![CDATA[You can start dd with with a progress bar. How? $ dd if=/dev/sda &#124; bar -s XXXM &#62; /path/to/destiantion you might need to $ sudo apt-get install bar before]]></description>
			<content:encoded><![CDATA[<p>You can start dd with with a progress bar. How?</p>
<pre class="wp-code-highlight prettyprint">$ dd if=/dev/sda | bar -s XXXM &gt; /path/to/destiantion</pre>
<p>you might need to</p>
<pre class="wp-code-highlight prettyprint">$ sudo apt-get install bar</pre>
<p>before</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.artworkz.net/2011/11/26/get-a-progress-bar-for-dd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>get progress of dd</title>
		<link>http://blog.artworkz.net/2011/11/26/get-progress-of-dd/</link>
		<comments>http://blog.artworkz.net/2011/11/26/get-progress-of-dd/#comments</comments>
		<pubDate>Sat, 26 Nov 2011 15:23:33 +0000</pubDate>
		<dc:creator>mathse</dc:creator>
				<category><![CDATA[scripting]]></category>
		<category><![CDATA[bash]]></category>

		<guid isPermaLink="false">http://blog.artworkz.net/?p=7</guid>
		<description><![CDATA[Guess you clone a disk with dd, which can take a long time. After some hours you like to know how far has the program been gone so far. Open up a new shell and put in $ kill -USR1 &#8230; <a href="http://blog.artworkz.net/2011/11/26/get-progress-of-dd/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Guess you clone a disk with dd, which can take a long time. After some hours you like to know how far has the program been gone so far. Open up a new shell and put in</p>
<pre class="wp-code-highlight prettyprint">$ kill -USR1 $(prgep dd)</pre>
<p>&#8230; and you gonna get something like</p>
<pre class="wp-code-highlight prettyprint">xxx bytes (xx MB) copied, xxx s, x MB/s</pre>
<p>&#8230; and the dd progress doesnt get killed.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.artworkz.net/2011/11/26/get-progress-of-dd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

