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:

Monday, June 15, 2009

Kyoto subway

Recently I visited Kyoto (Japan) for business. Before the visit I was looking for some info about how to use subway, if there are English signs and is it easy to use for a foreigner (yes, its very easy!). I could not found much info about this, so when I was in Kyoto I decided to take some pictures of Kyoto subway station next to my hotel.

I was using everyday Karasuma Line to get from my hotel (i.e. Gimmond hotel - it have no complains about this hotel) to my destination. The Gimmond hotel is just next to station K08 (i.e. Karasuma Oike). So I took some pictures from this station:





Kyoto subway map


This map is taken from this website.

Buying tickets


To my surprise using tickets wending machines, buying tickets and using subway was very easy. So I was basically traveling from station K08 to station K01 (the cost was 280 yen) and from K08 to K11 (i.e. main Kyoto station, cost 210 yen). So to use the subway we off course need to buy tickets. This is done using tickets vending machines available on each station:

To buy tickets it:

1. First check how expensive tickets you have to buy for your destination. You do this buy analysis subway map board above the wending machines (see above picture).

2. Put required amount of money to the wending machine. You can put more. For example if you want to go from K08 to K01 it costs 280 yen. You can put 500 yen coin or a 1000 yen bill into the wending machine or more. The machine will return you the change.

3. Once you put some money into the machine, the machine shows you the available tickets for this price:
4. You select thicket that you want and you collect the ticket and change if necessary:

5. When you have tickets you go to subway gates and use it there to "tag in". At your destination you use it again to "tag off". Or just follow the crowd:-) It's worth noticing that at the destination station when you "tag off" your tickets is automatically taken by the gate, so you loose it. If you want to keep it and have a recite, because for example you want a refund from your company for the tickets, you should not "tag off" using gates. Instead go to a booth next to the gates, there will be a subway stuff person and ask him for a recite. He will give you a red, rectangular stump on your ticket (see below):

Basically there are no problems using the subway in Kyoto. There are plenty of English signs next to Japanese ones, so everyone that knows a little bit of English should be fine. The only challenge at the very beginning might be buying tickets, but I hope that my post will help with this.

Some other sites in English about Kyoto public transport

http://www.city.kyoto.jp/koho/eng/access/transport.html
http://www.japanvisitor.com/index.php?cID=424&pID=1730
http://urbanrail.fotopic.net/c1174303.html

Sunday, June 14, 2009

Mathematica: xset: bad font path element (#23)

I have Mathematica 7.0 installed on a Linux server with CentOS 5.2. I'm using my PC (now Arch Linux) to x forwad (ssh -Y login@server) mathematica from the server to my PC. Unfortunately I was getting error xset: bad font path element (#23), possible causes are:
Directory does not exist or has wrong permissions
Directory missing fonts.dir
Incorrect font server address or syntax
After 20-30 seconds I was getting the following window:
This is a common problem and the solution is here. For clarity I write what I did:
  1. From Mathematica's CD I unpacked /Unix/Files/Fonts/contents.tar.gz into my home directory in my Arch Linux PC. After unpacking the font path was: /home/W/SystemFiles/Fonts/Type1
  2. I added this path to my font path: xset fp+ /home/W/SystemFiles/Fonts/Type1; xset fp rehash
  3. I chacked if the new path was included: xset q
  4. I logged into the serwer using ssh -Y login@server and started mathematica and it worked!