Archive for the ‘linux’ Category

Cygwin/X: disappering mouse pointer

Thursday, November 15th, 2007

Remember to start the X system using startxwin.bat not startx. With startx I lose the mouse cursor/pointer when I´m over a X window.

cygwin: setup.exe crashes whem upgrading packages

Monday, November 5th, 2007

I´ve run into a very strange problem.

Every time I run setup.exe and try to upgrade bash package

setup.exe crashes with the familiar “setup.exe has generated errors and will be close by windows. you will need to restart the program. An error log is beign created”. The solution I found is for bash package but I guess it also work for other packages as well

After googling a bit I found the this mail thread . But there was no solution posted into the thread so I tried to contact the Mario Frasca (one of the participants in the mail thread) to see if he found any solution to the problem. Well, he did. He sent me a mail telling me that William Crosmun resolved his problem.

It seems that /etc/setup/bash.lst.gz become corrupted

and if you delete it

and retry the upgrade now everything should work.

UPDATE: Please make a backup of the file before deleting it. If deleting the file solve the issue then please fill a bug report at cygwin and include that file. Or post a comment here and I will try to take care of it.

Hope it helps. Remember that if your setup.exe crashes while upgrading a package other than bash you should try to delete otherpackage.lst.gz instead of bash.lst.gz.

bash: clear: command not found

Wednesday, September 26th, 2007

If your are getting “bash: clear: command not found” on you first install of cygwin you have to make sure that you include ncurses packages in your cygwin installation. clear.exe doesn´t come in the standard installation. You must include ncurses to get clear.exe in your system. If you are using bash you can use Ctrl-L and get the same result though.

UPDATE: ncurses is a cygwin package in libs category. You can install it using the the Cygwin Setup utility (just run setup.exe again). See screenshot below

How to redirect your root web directory to a subfolder with .htaccess

Thursday, September 6th, 2007

If you tried (like me) to redirect your / (root) web directory to a subfolder (like /wp/) modifying .htaccess in this way:

Redirect 301 / http://rubenlaguna.com/wp/

You probably found that it didn’t work. The browser will end up in an endless loop of redirections. Firefox will complain with this error message:

The page isn’t redirecting properly Firefox has detected that the server is redirecting the request for this address in a way that will never complete. This problem can sometimes be caused by disabling or refusing to accept cookies.

The right way to accomplish the root to subfolder redirection is the following:

RedirectMatch permanent ^/$ http://rubenlaguna.com/wp/

Hope it helps

avahi and .local domain troubleshooting

Sunday, August 19th, 2007

I got the “avahi-daemon disabled because there is a unicast .local domain” but I have no .local domain so I was a little bit confused.

~$ sudo /etc/init.d/avahi-daemon restart
 * Restarting Avahi mDNS/DNS-SD Daemon: avahi-daemon                            
 * avahi-daemon disabled because there is a unicast .local domain

After a while I realized that my ISP is playing tricks with the DNS. It will never return a “DNS lookup failed”, it always resolve any dns name you pass to it. If the name is assigned it will return the proper IP but if the name is not assigned it will return the IP of the ISP portal. (Nice trick to get more page hits in their home page).

So in order to make avahi work I changed my dns server to OpenDNS ones. But avahi give me the same “…unicast .local domain” error. Then I found that I have to delete the “/var/run/avahi-daemon/disabled-for-unicast-local” first. Otherwise the “/etc/init.d/avahi-daemon” init script won’t notice that change in DNS.

Hope this helps.

How to install trac 0.10.4 and XmlRpcPlugin on a non-standard directory location

Friday, August 17th, 2007

First you need setuptools/EasyInstall:

cd $HOME/opt
wget http://peak.telecommunity.com/dist/ez_setup.py
mkdir -p $HOME/opt/easyinstall/lib/python2.4/site-packages
PYTHONPATH=$HOME/opt/easyinstall/lib/python2.4/site-packages python ez_setup.py --prefix=$HOME/opt/easyinstall

Next, trac:

cd $HOME/opt
wget http://ftp.edgewall.com/pub/trac/trac-0.10.4.tar.gz
tar xvzf trac-0.10.4.tar.gz
cd trac-0.10.4
python setup.py install --prefix=$HOME/opt/trac
cd ..
rm -rf trac-0.10.4
cd trac
PYTHONPATH=$HOME/opt/easyinstall/lib/python2.4/site-packages/:$HOME/opt/trac/lib/python2.4/site-packages/  bin/trac-admin $HOME/testtracenv initenv

Then the xmlrpcplugin:

cd $HOME/opt
wget -O xmlrpcplugin.zip  'http://trac-hacks.org/changeset/latest/xmlrpcplugin?old_path=/&filename=xmlrpcplugin&format=zip'
unzip xmlrpcplugin.zip
cd xmlrpcplugin/0.10/
PYTHONPATH=$HOME/opt/easyinstall/lib/python2.4/site-packages/ python setup.py bdist_egg
cp dist/*.egg $HOME/testtracenv/plugins
cat <<EOF >>$HOME/testtracenv/conf/trac
.ini
> [components]
> tracrpc.* = enabled
> EOF

And now you can test your installation:

cd $HOME/opt/trac
PYTHONPATH=$HOME/opt/easyinstall/lib/python2.4/site-packages/:$HOME/opt/trac/lib/python2.4/site-packages/  bin/tracd -p 8080 $HOME/testtracenv

And point your browswer to http://localhost:8080/testtracenv/xmlrpc if it returns a Forbidden: XML_RPC privileges are required to perform this operation then the installation is complete.

forbidden.png

You start using XML_RPC only need to do assign permissions for users using trac-admin, to enable xml_rpc for the anonymous user type this:

PYTHONPATH=$HOME/opt/easyinstall/lib/python2.4/site-packages/:$HOME/opt/trac/lib/python2.4/site-packages/  bin/trac-admin $HOME/testtracenv permission add anonymous XML_RPC

Hope this helps

Scripts to rename avi files from TV Shows

Thursday, July 5th, 2007

If you got a lot of ill-named files like:

$ ls
S01E03.The.Sopranos.S01E03.Denial.Anger.Acceptance.avi
The.Sopranos.1x04.Meadowlands.avi
The.Sopranos.S01E01.The.Sopranos.avi
The.Sopranos.S01E02.46.Long.avi
The.Sopranos.S01E06.Pax.Soprana.avi
The_Sopranos.105.College.avi

that your divx player can’t sort properly and you want to end up with something like:

$ ls
1x01.avi  1x02.avi  1x03.avi  1x04.avi  1x05.avi  1x06.avi  

you can use the following script in this way:

cd /path/to/avi/files
../script.sh|sh

and if you want to do the same thing to srt files then:

cd /path/to/srt/files
../script.sh srt|sh

As an example the script will normalize any of the following patterns S01E03, 103,1×03, or just 03 to 1×03.

The contents of script.sh :

#!/bin/bash
ext=$1
if [ ! $ext ]; then
  ext="avi"
fi
FILES=`find . -iname "*.$ext" -printf "%p\n"`
IFS="
"
for i in $FILES; do
 
dirname=`dirname $i`
g=`echo $i|perl -e '<STDIN> =~ m/S\d?(\d)E(\d+)/i; $1 and  print $1 . "x" . $2'`
 
if [ ! $g ]; then
  g=`echo $i|perl -e '<STDIN> =~ m/(\d)x(\d\d)/i; $1 and  print $1 . "x" . $2'`
fi
if [ ! $g ]; then
g=`echo $i|perl -e '<STDIN> =~ m/(\d)(\d\d)/i; $1 and print $1 . "x" . $2;'`
fi
if [ ! $g ]; then
  g=`echo $i|perl -e '<STDIN> =~ m/(\d\d)/i; $1 and print "1x" . $1'`
fi
 
if [ $g ]; then
 g="$dirname/$g.$ext"
 if [[ "$g" != "$i" ]]; then
   echo "if [ ! -e \"$g\" ]; then mv  \"$i\" \"$g\"; fi"
 fi
fi
 
done

Synchronize bash history among different machines

Wednesday, May 30th, 2007

Today I finally decide to make a script to keep my bash_history synchronized among all the machines I use. It’s a simple script that retrieves all the .bash_history files from all my machines, merges all the files into one, sort it, removes the duplicated lines and write it back to all the machines. The only drawback is that the original ordering of the history files is lost due to the alphabetical sorting step (needed to remove the duplicated lines).

WARNING: Make sure that your history file size limit is big enough to hold all the combined history files. Otherwise you’ll lose some of the entries. You can go to this post for reference on how to change the history file limits

Here’s the script:

 
echo copying local history file
history -a
cp .bash_history full_history
 
HOSTS="machine1.example.com machine2.example.com"
for i in $HOSTS; do
  echo copying history file from $i
  scp $i:~/.bash_history tmp_history.txt
  cat tmp_history.txt >>full_history
  wc -l tmp_history.txt
  wc -l full_history
done
 
 
echo sorting the new history file and removing duplicates
sort full_history|uniq >uniq_history
rm full_history
 
echo replacing history file with the new one
mv uniq_history .bash_history
echo reloading bash history from file
history -c
history -r
 
 
wc -l .bash_history
 
 
for i in $HOSTS; do
  echo backing up .bash_history in $i
  DATE=`date '+%Y%m%d%H%M%S'`
  ssh $i "cp ~/.bash_history ~/.bash_history$DATE"
  echo replacing .bash_history in $i
  scp .bash_history $i:~/.bash_history
done

Scrolling fast with the mousewheel triggers history back and forth

Friday, April 20th, 2007

Get FirefoxI’m observing an strange firefox behavior when I scroll the page using the mouse wheel. It goes back and forth through search history. So I googled a little bit and found that the KVM switch that I’m using it’s producing bogus key press event that firefox misinterprets. If you are running Linux the solution is simple as you can modify the X server configuration to ignore those events. But I cannot find a suitable solution for Windows.

Disabling history scroll in firefox (Usually triggered with Shift-<Wheel>) in about:config seems to have no effect in stopping this weird mouse wheel behavior.

Theorically changing the value of all mousewheel.horizscroll.with∗.action and mousewheel.with∗.action entries to 0 disables moving back/forward in history using the mouse wheel. Check this to know more about the meaning and purpose of mousewheel.∗ entries. But as I said It seems that doesn’t make any difference.

If you know the solution for this problem post it in the bug report

cvs [xxxxx]: received broken pipe signal

Thursday, March 29th, 2007

Today I received this error message when issuing a cvs import to the cvs repository

cvs [import failed]: received broken pipe signal

after googling a little bit I found this mail thread that led me to the following entry in the cvs manual about loginfo

Note that the filter program must read all of the log information or CVS may fail with a broken pipe signal.

so I took a look to the CVSROOT/loginfo and the line there was

ALL /usr/local/viewvc-1.0.0/bin/loginfo-handler %{sVv}

so I figured out that loginfo-handler from viewvc should be causing the problem. I went to the viewvc repository and find out the following comment on Revision 1518 of loginfo-handler

* bin/loginfo-handler Add some more debugging, and consume stdin so CVS’s pipe doesn’t back up (which causes an abort()).

I downloaded the latest version of loginfo-handler and tried to use it instead of the old one but I doesn’t work. You must upgrade to latest version of viewvc. So I tried another solution I modified a little bit the 1.0.0 loginfo-handler

*** loginfo-handler     2007-03-29 18:26:18.000000000 +0200
--- loginfo-handler-patched     2007-03-29 18:25:49.000000000 +0200
***************
*** 266,271 ****
--- 266,274 ----
      if len(sys.argv) > 3:
          error('Bad arguments')

+     debug('Discarded from stdin:')
+     debug(map(lambda x: '   ' + x, sys.stdin.readlines())) # consume stdin
+
      repository = cvsdb.CleanRepository(repository)
      directory, files = fun(arg, repository)

and now it seems to work.

UPDATE:: There is another way (easier) to solve this problem without editing loginfo-handler just change the line

ALL /usr/local/viewvc-1.0.0/bin/loginfo-handler %{sVv}

in your /CVSROOT/loginfo file with

ALL (/usr/local/viewvc-1.0.0/bin/loginfo-handler %{sVv};cat) >/dev/null

this also consumes all stdin data upon completion avoiding the received broken pipe signal.