<?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>Unix HOWTOs and Tips &#187; Utilities</title>
	<atom:link href="http://blog.bulsynt.org/category/utils/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.bulsynt.org</link>
	<description>Short unix command line administration tips and scripts</description>
	<lastBuildDate>Wed, 30 Oct 2019 07:51:49 +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>Execute identical commands in all running OpenVZ containers on a hardware host</title>
		<link>https://blog.bulsynt.org/2014/07/11/execute-commands-in-all-openvz-containers-on-a-hardware-host/</link>
		<comments>https://blog.bulsynt.org/2014/07/11/execute-commands-in-all-openvz-containers-on-a-hardware-host/#comments</comments>
		<pubDate>Fri, 11 Jul 2014 09:12:45 +0000</pubDate>
		<dc:creator>Delyan Angelov</dc:creator>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[OpenVZ]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Utilities]]></category>

		<guid isPermaLink="false">http://blog.bulsynt.org/?p=166</guid>
		<description><![CDATA[Suppose, that you have to execute some identical commands on all your running OpenVZ containers. For example you may want to check their disk usage, or ban an IP on all of them, or force a restart of their webserver for some reason. Typing the same commands over and over again is tiresome, and error [...]]]></description>
			<content:encoded><![CDATA[<p>Suppose, that you have to execute some identical commands on all your running OpenVZ containers. For example you may want to check their disk usage, or ban an IP on all of them, or force a restart of their webserver for some reason. Typing the same commands over and over again is tiresome, and error prone.  Suppose also, that you do not have an automated system like <a href="http://www.ansible.com/" title="Ansible" target="_blank">Ansible</a> already (which by the way, I highly recommend) ...</p>
<p>Do not worry, just follow these steps:</p>
<p>1) Save the following script as allvpses_do, somewhere on your PATH, and make it executable:</p>
<pre class="brush:bash">
#!/bin/bash

THECMD=$*

for i in `vzlist -o veid -H|  xargs`; do
   echo "============================  VPS: $i: CMD: $THECMD ===================================";
   echo "$THECMD" | vzctl exec $i - | grep --line-buffered -v 'Executing command:' | sed -e "s@^@VPS $i: @gm"
   echo;
done
</pre>
<p>2) Run a test command like this:</p>
<pre class="brush:bash">
allvpses_do uptime
</pre>
<p>... or, you can try:</p>
<pre class="brush:bash">
allvpses_do 'iptables --list -nv|grep DROP'
</pre>
<p>3) Enjoy your puppet master powers <img src='https://blog.bulsynt.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>https://blog.bulsynt.org/2014/07/11/execute-commands-in-all-openvz-containers-on-a-hardware-host/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple PHP cyr2lat command line transliteration filter from bulgarian to latin</title>
		<link>https://blog.bulsynt.org/2011/10/30/simple-php-cyr2lat-command-line-transliteration-filter-from-bulgarian-to-latin/</link>
		<comments>https://blog.bulsynt.org/2011/10/30/simple-php-cyr2lat-command-line-transliteration-filter-from-bulgarian-to-latin/#comments</comments>
		<pubDate>Sun, 30 Oct 2011 12:04:55 +0000</pubDate>
		<dc:creator>Delyan Angelov</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Utilities]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[cyr2lat]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[romanization]]></category>
		<category><![CDATA[slug]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[transliteration]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://blog.bulsynt.org/?p=8</guid>
		<description><![CDATA[Sometimes you need to easily convert some Cyrillic Bulgarian text to its latin equivalent (a process known as "romanization", see Romanization of Bulgarian ). A possible use case scenario is making slugs for urls, containing bulgarian. Since it is a common task, in the best Unix tradition, it is very usefull to have a simple [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes you need to easily convert some Cyrillic Bulgarian text to its latin equivalent (a process known as "<strong>romanization</strong>", see <a href="http://en.wikipedia.org/wiki/Romanization_of_Bulgarian"><strong>Romanization of Bulgarian</strong></a> ).</p>
<p>A possible use case scenario is making <strong>slugs</strong> for urls, containing bulgarian.</p>
<p>Since it is a common task, in the best Unix tradition, it is very usefull to have a <strong>simple command line filter</strong>, into which you can pipe the cyrillic text, and producing the romanized version in its output.</p>
<h2>Here is a simple version of the command line filter cyr2lat, written in php, that does just that:</h2>
<pre class="brush:php">#!/usr/bin/env php
&lt;?php
$cyr  = array('а','б','в','г','д','е','ж','з','и','й','к','л','м','н','о','п','р',
              'с','т','у','ф','х','ц','ч','ш','щ','ъ','ь','ю','я',
              'А','Б','В','Г','Д','Е','Ж','З','И','Й','К','Л','М','Н','О','П','Р',
              'С','Т','У','Ф','Х','Ц','Ч','Ш','Щ','Ъ','Ь', 'Ю','Я' );
$lat = array( 'a','b','v','g','d','e','zh','z','i','y','k','l','m','n','o','p','r',
              's','t','u','f' ,'h' ,'ts' ,'ch','sh' ,'sht' ,'a' ,'y' ,'yu','ya',
              'A','B','V','G','D','E','Zh','Z','I','Y','K','L','M','N','O','P','R',
              'S','T','U','F' ,'H' ,'Ts' ,'Ch','Sh' ,'Sht' ,'A' ,'Y' ,'Yu' ,'Ya' );

$in = fopen ("php://stdin","r");
while($line = fgets($in)){
    echo str_replace($cyr, $lat, $line);
}</pre>
<hr />
<p><a title="Download the source of cyr2lat.php" href="http://blog.bulsynt.org/wp-content/uploads/2011/10/cyr2lat.php_.txt">Source of cyr2lat.php</a></p>
<p>To use it, just save it to a file named cyr2lat.php, then make this script executable by:</p>
<blockquote><p><strong>chmod 755 cyr2lat.php</strong></p></blockquote>
<p>... and possibly move it to a location in your path:</p>
<blockquote><p><strong>mv cyr2lat.php /usr/local/bin</strong></p></blockquote>
<p>or</p>
<blockquote><p><strong>mv cyr2lat.php ~/bin</strong></p></blockquote>
<p>After this, you can run for example:</p>
<blockquote><p><strong>echo "Това е текст на кирилица" | cyr2lat.php</strong></p></blockquote>
<p>and you will get:</p>
<blockquote><p>Tova e tekst na kirilitsa</p></blockquote>
<p>&nbsp;</p>
<p><strong>NB:</strong> This filter <strong>assumes that the input text is in the utf8 encoding</strong>. If you have an input text in the cp1251 encoding, just pipe it first through <strong>iconv</strong>, like this:</p>
<blockquote><p><strong>echo "Това е пак текст на кирилица, но този път с кодировка cp1251" |iconv -fcp1251 -tutf8 |cyr2lat.php</strong></p></blockquote>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.bulsynt.org/2011/10/30/simple-php-cyr2lat-command-line-transliteration-filter-from-bulgarian-to-latin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using jed with different encodings &#8211; utf8 and cp1251.</title>
		<link>https://blog.bulsynt.org/2011/03/06/how-to-use-jed-with-different-encodings-utf8-and-cp1251/</link>
		<comments>https://blog.bulsynt.org/2011/03/06/how-to-use-jed-with-different-encodings-utf8-and-cp1251/#comments</comments>
		<pubDate>Sun, 06 Mar 2011 01:22:40 +0000</pubDate>
		<dc:creator>Delyan Angelov</dc:creator>
				<category><![CDATA[Utilities]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[cp1251]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[jed]]></category>
		<category><![CDATA[locale]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[utf8]]></category>
		<category><![CDATA[windows1251]]></category>

		<guid isPermaLink="false">http://blog.bulsynt.org/?p=3</guid>
		<description><![CDATA[Maintaining websites through remote ssh connections, requires using console editors which should start fast, do not require huge amounts of memory and are easy to use. The powerfull editors Vim and Emacs are not good for this task - although VIM is virtually guaranteed to be installed and it is fast, can be customized and [...]]]></description>
			<content:encoded><![CDATA[<p>Maintaining websites through remote ssh connections, requires using console editors which should start fast, do not require huge amounts of memory and are easy to use.</p>
<p>The powerfull editors Vim and Emacs are not good for this task - although VIM is virtually guaranteed to be installed and it is fast, can be customized and so on, it is hardly easy to learn. Emacs may be easier, it has menus and tutorial, it is very customizable, but is not too fast to start.</p>
<p>In contrast, <strong><a title="Jed" href="http://www.jedsoft.org/jed/download.html" target="_blank">Jed</a></strong> is a very light weight editor which is ideal for quick changes, because it starts instantly, supports syntax highlighting for many common programming languages and has good UTF8 support. It has emacs like macro recorder, buffers, and auto indenting too. It also supports emacs keyboard shortcuts by default, so if you use emacs for longer programming sessions, you probably will like jed when you need to edit quickly some remote files.</p>
<p>Unfortunately bulgarian texts (and sites) are often written using 2 different common encodings, and so there is a catch - you need some tweaks for your programs (and jed in particular), to support both encodings equally well:</p>
<p>In order to edit utf8 files with <strong>jed</strong>, first, you need to have the correct bulgarian locale for utf8 generated.<br />
You can do this using this command:</p>
<pre class="brush:shell">sudo localedef -i bg_BG -f UTF-8 bg_BG.UTF8</pre>
<p>You can install <strong>jed</strong> and some <strong>jed</strong> goodies with the following instructions (Debian/Ubuntu):<br />
<strong><code></code></strong></p>
<pre class="brush:shell">sudo apt-get install jed jed-extra jedstate</pre>
<p>For RedHat/Centos, try to google for a <strong>jed</strong> rpm, or try:</p>
<pre class="brush:shell">wget  ftp://ftp.pbone.net/mirror/centos.karan.org/el5/extras/testing/i386/RPMS/jed-0.99.18-5.el5.kb.i386.rpm
rpm -i jed-0.99.18-5.el5.kb.i386.rpm</pre>
<p>Next, you add these lines to your <strong>.bashrc</strong> file:</p>
<pre class="brush:shell">alias jed.cp1251='LANG=C jed'
alias jed.utf8='LANG=bg_BG.UTF-8 jed'</pre>
<p>Restart your shell, or do:</p>
<pre class="brush:shell">source ~/.bashrc</pre>
<p>in your current shell, so that the changes can be applied.</p>
<p>After all this preparation, when you want to edit a file encoded using utf8, do it like this:<br />
<code><strong></strong></code></p>
<pre class="brush:shell">jed.utf8    FILENAME</pre>
<p>For cp1251/windows1251, the command should be:</p>
<pre class="brush:shell">jed.cp1251   FILENAME</pre>
<p>&nbsp;</p>
<p>Note, that the selected encoding of your terminal application should match the encoding of your editor, or else you will see some funny characters instead of the proper ones. For this and other reasons, I recommend you to use the KDE's <strong>konsole</strong> application. It is stable, has good internationalization support, and it is pretty fast, even when you have a large scroll buffer.</p>
<p>You can also use <strong><a title="PuTTY" href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html" target="_blank">PuTTY</a></strong> in case you are trapped in a windows only shop <img src='https://blog.bulsynt.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  .</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.bulsynt.org/2011/03/06/how-to-use-jed-with-different-encodings-utf8-and-cp1251/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
