full of … these

Shell tools, today is sed’s day

Posted: December 4th, 2010 | Author: | Filed under: shell | Tags: , , , , , , , | No Comments »

When you have to deal with shell scripting and task automation you need powerful tools.

I will post some basic usage examples to prove how useful sed can be when you have to modify a large number of files.

Here the simple one.
You have several files and you want a word replaced in all of them.

sed -i 's/apache2/httpd/g' files*.conf

This will modify the file matching the pattern files*.conf replacing “apache2″ with “httpd”
Removing -i will print the result on the console.

Now, the really useful one, the one that will save you a lot of time.
The problem you have is: 100+ config files that needs to be modified by adding four lines in a special position in the files.

sed -i '/RewriteEngine/i \
\n<Location \/aaa>\n\tProxyPass ajp\:\/\/127.0.0.1\:8019\/aaa\n\tProxyPassReverse ajp\:\/\/127.0.0.1\:8019\/aaa\n\<\/Location\>\n' files*.conf

-i will modify the files by adding before “RewriteEngine" the text:


empty line
<Location/aaa>
<tab>ProxyPass ajp://127.0.0.1:8019/aaa
<tab>ProxyPassReverse ajp://127.0.0.1:8019/aaa
</Location>
emptyline

Now think about adding these lines in every single file, one by one, from 1 to 100, each in an exact position, some of the configs having two or more sections to be added.

Piece of cake with sed.


Customer satisfaction

Posted: October 28th, 2010 | Author: | Filed under: personal | Tags: , | No Comments »

[10/28/2009 2:13:31 PM] Wxxxxx Hxxxxxx: I admire your will power.
[10/28/2009 2:25:25 PM] Wxxxxx Hxxxxxx: I understand.  You’re the sort of person whom I really admire – people who can do things with their hands.

[10/27/2010 11:12:05 AM] Txxxxx Fxxxx: from a certain “distance” the time working with you was really cool
[10/27/2010 11:12:39 AM] Txxxxx Fxxxx: and I remember you as one of the most .. let’s say friendly/happy guys there

Two different guys almost the same time.
These words made me so happy and fulfilled. You can’t buy this…


trac: already updated: Error binding parameter 3 – probably unsupported type

Posted: October 20th, 2010 | Author: | Filed under: howto, linux | Tags: , , , , | No Comments »

I’m sick today, but, here is a short one.

If the user cannot log in into trac after a self password reset and you receive this message:

user.name already updated: Error binding parameter 3 - probably unsupported type.

all you need is to delete the cached users session in the sqlite database.

First make a backup:  cp trac.db trac.db-backup
Now you have to find the sessions stored in the database:
sqlite2 trac.db
select * from session_attribute;

Find the user with the problems and delete his data:
DELETE FROM session_attribute WHERE sid = "user.name";

Now test.
Please do backup the database first.


Windows XP, suddenly “USB device not recognized” message

Posted: September 21st, 2010 | Author: | Filed under: howto, idiots | Tags: , , , , , | No Comments »

USB stopped working, suddenly! F#uck! Nothing on USB is working, but it did! WTF can you do?

On MS support the KB articles are not offering a straight to the point solution for this.

So, I have searched the internet and after a few searches I have found this article (Google PR 3 page):

http://www.online-tech-tips.com/computer-tips/usb-device-not-recognized/

The answer is:

UNPLUG YOUR COMPUTER FROM THE POWER SUPPLY!!! and wait a few minutes to have all residual power consumed.

So, I did it.

And, it worked.

I had a 3 m USB cable extension for a USB WIFI adapter and, after removing it, is all good. It works!!!

Later edit:

This is a bit extreme, it still works if you shutdown the computer, unplug the power cord, push the buttons of the computer a few times, plug-in USB devices and wait for a minute or so.

One cause of this may be the grounding of the appliances, high density of wireless devices, unshielded USB cable, or, a combination of these.


Office Word 2003/2007 mouse hourglassing (blinking)

Posted: June 29th, 2010 | Author: | Filed under: howto, idiots | Tags: , , , , | No Comments »

My buddy with the gmail account problems in Outlook 2007 said today that the Word’s behavior is odd and the mouse cursor is switching fast between edit vertical line (text select) and the hour glass.

Investigating and applying different solutions including complete reinstall, rename Normal.dot or delete Data and Options sections from registry, uninstalling using revo uninstaller didn’t fixed the problem.

So, I went back to forums and after half an hour of reading I have found that the default printer may cause this problem.

Setting (the) other printer as default one or uninstalling it fixed the problem.

Now I have to find other/better drivers because each time when he will need to print something from Word he will need to select another printer.

Of course OpenOffice has no problems at all :)