Share keyboard and mouse between multiple Windows and Linux

I love my (Ubuntu) Linux box however time to time I have to switch to Windows box, this involves having two keyboards and mouses which can get very confusing. I know you can ssh into Linux box using putty from windows however I want to be able to switch from both using single keyboard and mouse. Enter Synergy, this app helps you to do just that. So here are the steps

1./ Install Synergy: On your Ubuntu machine type ‘apt-get install synergy’ and on windows, download synergy .exe file.
2./ On your Ubuntu create /etc/synergy.conf

section: screens

section: aliases

section: links
right = windows-desktop
left = ubuntu-desktop

ubuntu-desktop and windows-desktop are your hostname for your linux and windows box respectively.

option aliases, allows you to specify ip addresses incase you do not have dns name.

option links, specifies which computer to go to when the mouse is off screen. On this occasion, if the mouse goes far right of the ubuntu-desktop screen, it only then jumps on to windows-desktop. if the mouse goes far left of the windows-desktop screen, it only then jumps on to ubuntu-desktop screen.

Now, save your config file and execute using ‘synergys -f –config /etc/synergy.conf’. option -f tells synergy to run in the forground so that you can see what is happening.

3./ On Windows run synergy and type in your host name ip adress (in this case ip address of ubuntu-desktop).

…and then test if it is connecting to your Ubuntu machine. Once it connects, then click on start.


(Putty) Pageant autoload private key

If you are remotely connecting to your linux desktop using putty and you want to avoid typing your password then pageant is your answer however pageant has a memory of a gold fish. It cannot remember your private key once you have exited from the application. So to get pageant to remember, here is a little trick.

Lets say your private keys are located at “C:\putty\cert”, create a batch file autoloader.cmd and add the following lines

— start here —

if exist "C:\putty\cert\your-linux1.ppk" (set KEYS="C:\putty\cert\your-linux1.ppk")

if exist "C:\putty\cert\your-linux2.ppk" (set KEYS=%KEYS% "C:\putty\cert\your-linux2.ppk")

if not defined KEYS exit
start /d"c:\putty" pageant.exe %KEYS%

— end here —

An Introduction to IIS: WWW Service Setup

You have setup WWW Services so what now. In this section we are going to get familiar with some of the functionality in Microsoft Management Console which allows us to configure our WWW Service. Okay enough chat lets get started…

There are two options to configure WWW Service either using Internet Information Service Manager (under Control Panel -> Administrative Tools) or Microsoft Management Console. You can access these tools through command line by either typing inetmgr for IIS Manger or mmc for Microsoft Management Console. It really does not matter which one of these tools you use, they both “have same functionality” however Microsoft prefers you to use MMC ’cause it is moving towards that direction to configure all your services. Do not worry, if you do not know how to use MMC, I have created a tutorial for that which you can find under IIS category.

Here is a screen snap of my MMC in action.
Microsoft Management Console

…Again do not worry if you are not familiar with MMC, there is a tutorial for it.

Topics we are going to be covering are

  • Web Site Tab
  • Home Directory Tab
  • Security Tab
  • Custom Errors Tab
  • HTTP Headers Tab
  • Documents and Operators Tab
  • ISAPI Tab
  • Making Virtual Directory

Web Site Tab

1./ In your Scope Pane right click on “Default Web Site” for Properties

Default website properties

Default website properties dialog

On this tab we are going to take a look at some of the items.
1.1./ Web Site Identification
1.1.1./ Description: This field displays the description of the website that appears on our MMC. On this occasion it is set to “Default Web Site”, if we change it to… lets say “Website 1″… and then press “Apply”, the website description changes on our MMC.

Website description

1.1.2./ IP Address: This list the IP addresses of your net cards. One my machine, I have one net card so it lists just the one. At this time, I have set it to my IP address, so yours may be different

Web site identification ip-address

1.1.3./ Advanced: This button give us further configuration options to change IP addresses and default ports for browser and ssl socket

Web site identification advanced options

1.1.4./ TCP Port: this specifies which port to connect to during a browser request by default it is port 80 however you can specify it to some thing other than 80 which you then have to specify on your web browser. For this instance we are going to leave it as it is.

Web site identification TCP port

1.2./ Connections
1.2.1./ Connection Timeout: suppose the user is connected however they are not doing anything, you can specify how long to keep the connection open. In this case after 900 sec of idle time, it cuts the user connection.

Connections - Connection timeout

1.2.3./ Unlimited (Option available to Windows 2003 Server) : does what it says. It allow as many users to connect to your website.
1.2.4./ Limited To (Option available to Windows 2003 Server): If your web server resources are limited and you want to restrict the number of users connecting then this option is for you.

1.3./Enable Logging
1.3.1./ Enable Logging: you can have this option switched on or off depending if you want logging information. In this option you have several items they are Microsoft IIS Log File Format: Microsoft IIS log format is fixed ASCII text-based format which cannot be customised set by Microsoft NCSA Common Log File Format: It is another fixed ASCII text-based format which cannot be customised set by National Center for Suppercomputing Applications (NCSA) W3C Extended Log File Format: This is customisable ASCII text-based log format which is the default IIS log format. For our tutorial we are going to select this option.

1.3.2./ Properties: Pressing this button gives us options of when and where to create new log file. General Properties tab: you can specify when a new log file can be created hourly, daily, weekly, monthly, unlimited file size and when file size reaches a specified size. In our tutorial we are selecting daily.

Extended logging properties Log File Directory: this field allows us to specify a different directory other than the default directory. We are going to leave this on the default directory Extended Properties tab: This gives us list of items that we can have on our log file. Some of this options are selected for you by default however you can add more by checking the checkbox.

Extended properties tab

Home Directory Tab

2./ Specifies the location of your website directory.
2.1./ A directory located in this computer: this option tells IIS that the the website files are located on this computer.

Home directory tab - connecting to resources on this computer

2.1.1./ Local path: under local path you can define where your web site folder is. your web folder does not need to be Inetpub/wwwroot directory, you can have it any where in your computer as long as you tell IIS where to look for it. On this occasion we are going to leave it on its default settings.
2.1.2./ Permission settings: you have many options here; you can decide to give the client read, write, log visits, directory browsing and indexing. we are going talk about index later so do not worry about it at this instance. Read: this option gives the client, who is visiting your website to read the files on your website. we need this checked ’cause this is what we want the clients to be able to do. Write: this option gives the client to edit your script and we do not want that. It is useful to have if you are sharing files over the intranet however not over the internet. Directory browsing: this option allows clients to browse your server directory. This option needs to be switched off Log visits: this option logs client visits, we are going to talk about its importance later, for now we are going have this option checked Index this resource: this option we are going to talk about further later, for now have it checked.

2.2./ A shared located on another computer: if the website files are located on another computer then we can use this option.

Home Directory tab: connecting to resources in another computer

2.3./ A redirection to a URL: this allows to send the client to specified URL where you can select to send the client to the exact URL, directory within the specified URL and a permanent redirection to the URL specified.

Home Directory tab: redirecting to an URL

Directory Security Tab

3./ We need setup our directory security by selecting “Directory Security” on website properties
Directory Security tab: securing directory

3.1./ click on Edit under “Anonymous access and authentication control” and have anonymous access checked. This allows anonymous access which is the default setting on the internet and this is why you are not prompted for authentication when you try to access the website. That is that for now

Custom Error Tab

4./ In this session we are going to look at custom error tab which allows us to display our own message when an error occurs.
4.1./ In website properties, select “Custom Error” tab and select HTTP 404 error.

Directory Security tab: securing directory

4.2./ To edit HTTP error message select an error and click “Edit Properties”. In the new dialog box you can chose to display an alternative message file using the “Browse” button

Directory Security tab: securing directory

… continued

IIS error ‘8002801c’ Error accessing the OLE registry

After installing IIS5, I got an authentication dialog on my browser requesting username and password. When authentication failed, it gave me this error message below.

error '8002801c'

Error accessing the OLE registry.

/iisHelp/common/500-100.asp, line 17

… to get around this problem do
1./ Select Start, Run and then type inetmgr to display Internet Information Service Management tool
Internet Information Service
2./ Select local computer and Web Sites
3./ Right click on localstart.asp and select Properties
4./ Click on File Security tab, Edit and under Anonymous access type in your username and password.
5./ After that press OK
6./ Restart your IIS by right clicking local computer, All Tasks and Restart IIS…

How to setup IIS web server

Yet another installation manual for setting up IIS web server, matter of fact this is 1,070,000th on google search. Anyhoo, lets get on with it.

1./ first log on as the web server user.
2./ go to Start, Control Panel (if you’r Window XP user) and Add/Remove Programs
3./ select Add/Remove Windows Components
Add/Remove Programs
4./ select Internet Information Services (IIS)
5./ press Details… for advance options and select File Transfer Protocol (FTP) Service, SMTP Service and World Wide Web Service
Add/Remove Windows Components. After that press OK.
6./ to finish press next to continue with installation.
7./ you should have a new folder called Inetpub on your primary hard drive (which is C:\ drive).
8./ now type in http://localhost/ on your browser
Add/Remove Windows Components

…you are done.

PHP 4.4.9 throws ‘Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’’

Today, my website decided suddenly not to work and reported a syntax error however I had not made any changes to it. It gave me an error message

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}'

… I looked at all the braces and keywords and they all checked out fine. I looked at phpinfo() and found my PHP5.* had been downgraded to PHP4.* however this did not explain why the script did not work. I wrote this test class

class TestClass
	static $instance;

and to my surprise it threw the same error message as my website.

Here is the solution: PHP4.* does support the ‘static’ keyword however it supports it in the scope of a function and not in a ‘class’, example

function testFunction()
	static $instance = 0;
	echo "Instance value " . $instance;

So, only way to fix this is to upgrade to PHP5 which I did.