<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   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/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>Globalways Blog - Scripting (Bash/Perl)</title>
    <link>http://www.globalways.net/blog/</link>
    <description></description>
    <dc:language>de</dc:language>
    <generator>Serendipity 1.1.3 - http://www.s9y.org/</generator>
    <pubDate>Wed, 25 Aug 2010 07:48:01 GMT</pubDate>

    <image>
        <url>http://www.globalways.net/blog/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: Globalways Blog - Scripting (Bash/Perl) - </title>
        <link>http://www.globalways.net/blog/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Strace with multiple processes</title>
    <link>http://www.globalways.net/blog/archives/52-Strace-with-multiple-processes.html</link>
            <category>Scripting (Bash/Perl)</category>
    
    <comments>http://www.globalways.net/blog/archives/52-Strace-with-multiple-processes.html#comments</comments>
    <wfw:comment>http://www.globalways.net/blog/wfwcomment.php?cid=52</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.globalways.net/blog/rss.php?version=2.0&amp;type=comments&amp;cid=52</wfw:commentRss>
    

    <author>nospam@example.com (Uli Stärk)</author>
    <content:encoded>
    Usually, you trace a single process that does not give a helpful error message. But if you have to trace e.g. a webserver with multiple processes you have to type a lot. Here is a one-liner that makes it a little bit easier:
&lt;pre&gt;
strace -f -p $(ps -ea f| grep &lt;span style=&quot;color: red&quot;&gt;httpsd&lt;/span&gt; | cut -f 1 -d &quot; &quot; | xargs | sed -e &#039;s/ / -p /g&#039;) 1&gt;/tmp/strace.log 2&gt;&amp;1
&lt;/pre&gt; 
    </content:encoded>

    <pubDate>Wed, 25 Aug 2010 09:48:01 +0200</pubDate>
    <guid isPermaLink="false">http://www.globalways.net/blog/archives/52-guid.html</guid>
    
</item>
<item>
    <title>Dumping json-data in shell</title>
    <link>http://www.globalways.net/blog/archives/51-Dumping-json-data-in-shell.html</link>
            <category>Scripting (Bash/Perl)</category>
    
    <comments>http://www.globalways.net/blog/archives/51-Dumping-json-data-in-shell.html#comments</comments>
    <wfw:comment>http://www.globalways.net/blog/wfwcomment.php?cid=51</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.globalways.net/blog/rss.php?version=2.0&amp;type=comments&amp;cid=51</wfw:commentRss>
    

    <author>nospam@example.com (Uli Stärk)</author>
    <content:encoded>
    &lt;p&gt;When using web services, its sometimes hard to read the serialized json data. I wrote a small helper script to dump the contents&lt;/p&gt;

&lt;p&gt;File: /usr/local/bin/json_decode&lt;/p&gt;
&lt;pre&gt;
#!/usr/bin/php
&amp;lt;?php
error_reporting(E_ALL);
ini_set(&#039;display_errors&#039;,true);
if(!empty($argv[1])) {
        $json = file_get_contents($argv[1]);
}
else {
        $json = &#039;&#039;;
        while(!feof(STDIN)) {
                $json .= fgets(STDIN, 1024);
        }
}

$data = json_decode($json);

if($data === null) {
        fwrite(STDERR, &quot;Invalid json data\n&quot;);
        exit(1);
}

print_r($data);
&lt;/pre&gt;

&lt;p&gt;Usage:&lt;/p&gt;
&lt;pre&gt;
wget --quiet -O - &quot;http://domain.tld/file.json&quot; | json_decode
&lt;/pre&gt; 
    </content:encoded>

    <pubDate>Thu, 17 Jun 2010 15:58:09 +0200</pubDate>
    <guid isPermaLink="false">http://www.globalways.net/blog/archives/51-guid.html</guid>
    
</item>
<item>
    <title>for-loop in bash</title>
    <link>http://www.globalways.net/blog/archives/30-for-loop-in-bash.html</link>
            <category>Scripting (Bash/Perl)</category>
    
    <comments>http://www.globalways.net/blog/archives/30-for-loop-in-bash.html#comments</comments>
    <wfw:comment>http://www.globalways.net/blog/wfwcomment.php?cid=30</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.globalways.net/blog/rss.php?version=2.0&amp;type=comments&amp;cid=30</wfw:commentRss>
    

    <author>nospam@example.com (Uli Stärk)</author>
    <content:encoded>
    
&lt;p&gt;If you want to update several hosts at once you can use a for-loop in a shell to execute a command on serveral hosts&lt;/p&gt;
&lt;pre&gt;for i in 1  3 `seq 4 7` 9; do HOST=&amp;quot;1.2.3.$i&amp;quot;; ssh root@$HOST &lt;command&gt;; done;
&lt;/command&gt;&lt;/pre&gt;
&lt;p&gt;As you can see it is very easy to create a custom set of items to loop through. On the one hand you can use any value seperated by a space or you can create a sequence of numbers with the seq-command.&lt;/p&gt; 
    </content:encoded>

    <pubDate>Wed, 06 Aug 2008 14:45:30 +0200</pubDate>
    <guid isPermaLink="false">http://www.globalways.net/blog/archives/30-guid.html</guid>
    
</item>
<item>
    <title>Bash: Arithmetic operations using bash</title>
    <link>http://www.globalways.net/blog/archives/2-Bash-Arithmetic-operations-using-bash.html</link>
            <category>Scripting (Bash/Perl)</category>
    
    <comments>http://www.globalways.net/blog/archives/2-Bash-Arithmetic-operations-using-bash.html#comments</comments>
    <wfw:comment>http://www.globalways.net/blog/wfwcomment.php?cid=2</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.globalways.net/blog/rss.php?version=2.0&amp;type=comments&amp;cid=2</wfw:commentRss>
    

    <author>nospam@example.com (Markus Binder)</author>
    <content:encoded>
    
When using the bash shell sometimes you need arithmetic calculations (like plus, minus, multiply, divide) on variables and numbers.

&lt;strong&gt;Simple division by 5&lt;/strong&gt;

&lt;pre&gt;
i=10
echo $[$i/5];
2
&lt;/pre&gt;

&lt;strong&gt;Better use-case: do 10 times the same command&lt;/strong&gt;

&lt;pre&gt;
host ~ # i=0; while [ $i -lt 10 ]; do echo $i; i=$[$i+1]; done
0
1
2
3
4
5
6
7
8
9
&lt;/pre&gt; 
    </content:encoded>

    <pubDate>Wed, 25 Jul 2007 12:06:17 +0200</pubDate>
    <guid isPermaLink="false">http://www.globalways.net/blog/archives/2-guid.html</guid>
    
</item>

</channel>
</rss>