Tuesday, July 28, 2009

Firefox: images don't load but work everywhere else

I had problem with one of my sites. When testing on firefox, some banners did not load. My site was sponsored so I had sponsors banners on my front page. The banners were located on the localhost i.e. <img alt="toyto logo" src="./images/sponsors/toyota.gif" />
<img alt="honda logo" src="./images/sponsors/honda.gif" />
Of course everything was fine in IE, Opera an Safari.

I found that my AdBlock Plus was blocking my banners because the following default filter in AdBlock Plus /[/^a-ik-z\d=+](get|web)?_?spons?(or(ed|s))?_?(links?(auto)?)?(pots?)?(\W|_|$)(?!.*sigalert)/The solution was to rename sponsors folder on my server to something else. I choose to rename it to friends. It worked.

Wednesday, July 22, 2009

bash: check size of all folders in a given directory

To list all folders in a given path

this can be usedfor f in ./* ; do if [ -d "$f" ]; then echo $f ; fi done;

To list sizes of all folders in a given path

To check the size of all folders in the current directory the above can be modified to use du -sh "$f" command: for f in * ; do if [ -d "$f" ]; then du -sh "$f" ; fi done;The command goes in a loop on every file in a current dir and if a given file is a directory, than the size is calculated.

To sort by folder size

for f in * ; do if [ -d "$f" ]; then du -s "$f" ; fi done | sort -nNote that in du command there is no -h option!

Monday, July 20, 2009

Using rsync to transfer files and directories from server

A file from a server to the local computer

rsync -v -e ssh W@server:~/some_file.tar.gz ~/local_dir

A directory from a server to the local computer

rsync -r -v -e ssh W@server:~/some_directory ~/local_dir Other info is here.

Thursday, July 09, 2009

VirtualBox on CentOS 5.3: port forwarding

I have installed VirtualBox 2.2.4 on a CentOS 5.3. As a guest OS I installed Ubuntu, and on that Ubuntu I made a LAMP server. So, what I wanted was to redirect all html requrest on port 80 of CentOS (host) to port 80 of Ubuntu (guest). This is similar problem to the previously described on Windows XP host. The difference is that this time my host was CentOS 5.3, and VirtualBox was running as a normal user, not as a root.

The first thing to do was to make VirtualBox to forward the ports. I did it by executing the following commands, as a normal user under which VirtulBox was running. VBoxManage setextradata "ubuntu-server" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/Protocol" TCP
VBoxManage setextradata "ubuntu-server" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/GuestPort" 80
VBoxManage setextradata "ubuntu-server" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/HostPort" 80
where "ubuntu-server" is the name of Ubuntu guest.

Than I wanted to start it in a headless modeVBoxHeadless -s ubuntu-server but I was getting the following error:Error: failed to start machine. Error message: NAT#0: configuration error: failed to set up redirection of 80 to 10.0.2.15:80. Probably a conflict with existing services or other rules (VERR_NAT_REDIR_SETUP).
Unknown error creating VM (VERR_NAT_REDIR_SETUP)
This error is due to the fact that in Linux systems only root can bind to ports below 1024, and not a normal user!. There are two possible solutions. First is to run VirtualBox as a root, the second is to redirect port 80 to port 8080 in the CentOS and the make VirtualBox to get connection from port 8080 of CentOS. I choose the second option. Therefore, I did as follows:

VBoxManage setextradata "ubuntu-server" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/Protocol" TCP
VBoxManage setextradata "ubuntu-server" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/GuestPort" 80
VBoxManage setextradata "ubuntu-server" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/HostPort" 8080
The above makes VirtualBox to redirect trafic from 8080 of CentOS to 80 of guest ubuntu-server. Than as a root I used iptables to redirect port 80 to 8080 in CentOS iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080To check if iptables command was succesfull I used iptables -t nat -L commandiptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
REDIRECT tcp -- anywhere anywhere tcp dpt:http redir ports 8080

Chain POSTROUTING (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
If OK save your iptables settings usingsudo /etc/init.d/iptables saveHope it will be useful. I also used VirtualBox 2.2, rather then VirtualBox 3.0, but I think the procedure will be similar.

The schematic illustration of what I did is below:



Wednesday, July 08, 2009

Install VirtualBox on CentOS 5

Go to the conclusions if you have no time for BS. If you have time the details of my installation of VirtualBox 2.2.4 on CentOS 5.3 are below.

1. I downloaded VirtuaBox rpm form virtualbox.org. In my case I downloaded VirtualBox-2.2.4_47978_rhel5-1.i386.rpm

2. Installed the rpm as a rootsu root -c "rpm -ivh VirtualBox-2.2.4_47978_rhel5-1.i386.rpm"
But I got the errorerror: Failed dependencies:
libSDL-1.2.so.0 is needed by VirtualBox-2.2.4_47978_rhel5-1.i386


3. So I installed SDL su root -c "yum install SDL" and I tried again su root -c "rpm -ivh VirtualBox-2.2.4_47978_rhel5-1.i386.rpm" and the installation failed Preparing... ########################################### [100%]
1:VirtualBox ########################################### [100%]

Creating group 'vboxusers'. VM users must be member of that group!

No precompiled module for this kernel found -- trying to build one. Messages
emitted during module compilation will be logged to /var/log/vbox-install.log.

Compilation of the kernel module FAILED! VirtualBox will not start until this
problem is fixed. Please consult /var/log/vbox-install.log to find out why the
kernel module does not compile. Most probably the kernel sources are not found.
Install them and execute

/etc/init.d/vboxdrv setup

as root.
The reason is that kernel-headers and kernel-develop packages were missing, so I installed them su root -c "yum install kernel-headers kernel-devel" Be sure that the install packages correspond to your kernel version! You can check this as follows: [W@localhost ~]$ uname -a
Linux localhost.localdomain 2.6.18-128.1.16.el5 #1 SMP Tue Jun 30 06:10:28 EDT 2009 i686 i686 i386 GNU/Linux
[W@localhost ~]$ rpm -q kernel-headers kernel-devel
kernel-headers-2.6.18-128.1.16.el5
kernel-devel-2.6.18-128.1.16.el5


4. I removed failed installation of VirtualBox su root -c "rpm -e VirtualBox-2.2.4_47978_rhel5-1.i386" and I tried again to install it. Again I got the same error. But this time the reason was that I did not have gcc installed. So I installed it su root -c "yum install gcc", removed failed installation of VirtualBox and tried again to install it: [W@localhost ~]$ su root -c "rpm -ivh VirtualBox-2.2.4_47978_rhel5-1.i386.rpm"
Password:
Preparing... ########################################### [100%]
1:VirtualBox ########################################### [100%]

Creating group 'vboxusers'. VM users must be member of that group!

No precompiled module for this kernel found -- trying to build one. Messages
emitted during module compilation will be logged to /var/log/vbox-install.log.

Success!
This time it worked!!

Concussion

First, download VirtualBox from virtualbox.org. Second, install four missing packages (at least I did not have these packages installed, they are on CentOS CDs/DVD, you can use pirut or yum to install them) su root -c "yum install SDL kernel-devel kernel-headers gcc" Third, install VirtualBox su root -c "rpm -e VirtualBox-2.2.4_47978_rhel5-1.i386" Fourth, add yourself to the vboxusers group su root -c "/usr/sbin/usermod -a -G vboxusers yourusername"Finally, start VirtualBox:[W@localhost ~]$ VirtualBox

Monday, July 06, 2009

Update of CentOS 5.2 to CentOS 5.3

There was no problems with the update. I just followed the instructions. Most importantly, after the update to CentOS 5.3, applications previously installed in CentOS 5.2 worked (i.e. Ansys 11SP1, Matlab 2008b, Mathematica 7, Abaqus 6.8).

Wednesday, July 01, 2009

ssh -X Error: Can't open display:

The error occurred when I was accessing a server (Arch linux) from a desktop (Mac X) using ssh -X username@serverip. In other words I wanted to X forward some apps from server to my desktop. First thing to do, I checked whether $DISPLAY variable on the server was setecho $DISPLAYIt was not. Then I checked the setting of my ssh daemon (sshd) on the server in /etc/ssh/sshd_config. I found that option X11Forwarding was not set, so I set it toX11Forwarding yes and I restarted the sshd. After this I logged in to the server again using ssh -X and this time echo $DISPLAY
localhost:11.0
Now X forwarding was working! It appears that $DISPLAY does not have to point to my desktop.

Tuesday, June 30, 2009

wine: remove Wine gnome menu

In my system (Arch Linux) after removing wine (sudo pacman -R wine), the Wine gnome menu was still in the Gnome Menus. To remove it, I had to delete it manualy from my .local folder:rm -rvf ~/.local/share/applications/wine

Thursday, June 18, 2009

python: numbers starting with zero are octagonal

I was debugging my script and I found that a number that starts from zero is different that the number without zero. This is because these numbers are octal literals. For example In [1]: a=23
In [2]: b=023
In [3]: a==b
Out[3]: False
In [4]: print a,b
23 19
It appears that when a number starts from zero it is treated as an octagonal number rather than decimal number. Good to know, as it is easy to make mistake.

Wednesday, June 17, 2009

CentoOS: problem to install Abacus 6.8

When I was installing Abacus 6.8 on CentOS 5.2 x86_64 I run into three problems. The first one was that installation script did not recognize my Linux distribution (i.e. CentOS 5.2), the second was that that after successful installation, I could not start freshly installed abacus because of missing one library, and the last problem was that the GUI would not start. Below more details on these problems are given, along with my solutions to them.

1. Unable to determine Linux Distribution

When a user (or a root) wants to install Abacus 6.8 on CentOS 5.2, at the beginning of installation process the error appears: "Unable to determine Linux Distribution". In another words, CentOS is not supported and the user should use Red Hat Enterprise or SuSE. The full list of the supported distributions is in the contents of the error and the error itself is shown below:
Checking system requirements for installation. This will
take just a moment...


***ERROR: One or more system tests have failed the minimum installation
requirements. The installation procedure will not continue.
Hit to view the output from this system check.

Checking for GNU Lib C version 2.3.2 or newer.
Pass - Found GNU Lib C Version 2.5.
WARNING: Problem parsing /etc/redhat-release to determine version of Red Hat.

Running system configuration checks for Linux/x86-64.
Please wait until all the needed information has been gathered...

System requirement status is:

Requirement: SuSE 9.3, 10.0, 10.1 or 10.2, SuSE Enterprise Linux 9.0
or 10.0, SuSE Enterprise Desktop 10, Red Hat Enterprise
3.0, 4.0 or 5.0, or Fedora Core 6.0
Products: All Abaqus Products
Status: Fail - Unable to determine Linux Distribution.

Requirement: GNU Lib C 2.3.2 or greater
Products: All Abaqus Products
Status: Pass - Found GNU Lib C 2.5, which was installed with
glibc-2.5-24.rpm.

Not all requirement checks succeeded.
The solution to this problem is quite easy. After going through some installation scripts, I found that, they relay on the file /etc/redhat-release. This file can be found in RHEL and CentOS. Therefore, instalation script checks the contents of this file, and if it does not find something familiar e.g. Red Hat Enterprise Linux AS 5, the error occurs and the installation stops. In CentOS 5.2. the contents of this file is just one line:[W@localhost ~]$ cat /etc/redhat-release
CentOS release 5.2 (Final)
Therefore, what can be done is to change this file temporary, just for the purpose of the installation of Abacus. I just add "Red Hat Enterprise Linux AS 5" as a second line /etc/redhat-release and the installation script should worked.
The installation went good, no more problems. The other two problems occurred after successful installation, when I wanted to start Abaqus.

Error while loading shared libraries: libstdc++.so.5

I installed Abaqus in /opt/abaqus68. During the first attempt to start Abaqus CAE or Viewer I got the error that there are was no libstdc++.so.5 library:[W@localhost ~]$ /opt/abaqus68/Commands/abq682 cae
/opt/abaqus68/6.8-2/exec/ABQcaeK.exe: error while loading shared libraries: libstdc++.so.5: cannot open shared object file: No such file or directory
Abaqus Error: Abaqus/CAE Kernel exited with an error.
This problem was easily solved, because CentOS 5.2 DVD comes with this library. So, I just installed it using pirut. To be specific I installed the following rpm: compat-ibstdc++-33-3.2.3-61.x86_64

Insufficient system resource available.

After installing the missing library, the finall error was "ValueError: Insufficient system resource available."[W@localhost ~]$ /opt/abaqus68/Commands/abq682 cea
Abaqus License Manager checked out the following license(s):
"cae" version 6.8 from abaqus.some.example.com
<6>.
ValueError: Insufficient system resource available.

Abaqus Error: Abaqus/CAE Kernel exited with an error.
Abaqus Error: Abaqus/Viewer exited with an error
This problem has something to do with X11 server and graphics hardware acceleration. My server does not have 3D graphic card, so no chance for hardware acceleration. The solution was to disable it by starting abaqus with and option -mesa:/opt/abaqus68/Commands/abq682 cae -mesaor/opt/abaqus68/Commands/abq682 viewer -mesaFinnaly, after some time spent on installing and starting Abaqus I and other users could use it: