9 Jul 2013

Crunchbang Linux - Hello World!

There's a tradition that when you write your first program in any programming or scripting language you write a program to display the words "Hello World". Here's how you can make a shell script file in Crunchbang Linux (it will work for other Linux distros too). This is similar to creating a batch file in the world of Windows command line.


Instructions
Right click on the desktop, click Text Editor

Geany (the text editor) will appear on the screen - enter the following:

#!/bin/bash

echo "Hello World!"


You should have something like this:



Click File | Save

Save the file as "HelloWorld.sh" (the .sh file extension is to indicate it's a shell script file)
The default place for it to be saved is in your home folder.

Right click on the desktop

Click Terminal 

Type the following command at the $ prompt:
chmod a+x HelloWorld.sh      [Enter]

The chmod command changes the attributes of the HelloWorld.sh file to make it executable. For more details about this command, click http://en.wikipedia.org/wiki/Chmod

To run the file type:
~/HelloWorld.sh    [Enter]

The ~ means 'home'. If you save your .sh file in a sub-folder you'd need to type ~/sub-folder/HelloWorld.sh for example.

The following screen shot shows what you should see.

The echo command in the .sh file is just like the same command from Windows, it displays text on the screen. In our case you can see it has displayed the words "Hello World!":



Conclusion
I know this doesn't seem very exciting but it is useful, I promise! In the world of Windows it is possible to create a command file or 'batch' file. The idea being that you can run a number of commands one after another. This is useful for automating common tasks. Here in Linux what we've done here is the basics of creating a shell script (batch) file. Of course you could add more commands to do any number of different tasks. The first line of the script file should be !#/bin/bash but otherwise you can do as you wish, enter any number of commands. Of course they must be valid Bash shell scripting commands.


References
A forum post with more details
http://www.linuxquestions.org/questions/linux-newbie-8/how-to-create-a-batch-file-in-linux-608655/

Chmod
http://en.wikipedia.org/wiki/Chmod

Bash Shell Scripting
http://en.wikipedia.org/wiki/Bash_shell

Bash Shell Scripting Tutorial
http://arachnoid.com/linux/shell_programming.html

More Crunchbang Linux articles
http://mgxp.blogspot.ch/search/label/Crunchbang


8 Jul 2013

Swisscom TV and Internet suddenly stop working

Introduction 
Today I came home from work and switched on Swisscom TV box and the TV - no signal! I tried the internet from my computer, I could connect to my wireless router but I could not 'see' the internet. The following is what I was getting when I tried to browse to any internet website:
"Your router still has no connection to the Internet."



I decided to login to my Router - this means I entered the IP address into my browser, typically it is http://192.168.1.1 but yours maybe different.
Enter the username admin
and your password (you should have this from when you first received your Swisscom Router).


The Router Configuration Overview screen (above) showed what I already knew, there was no connection between my Swisscom Router - the red X shows this! If you see this then of course you know the connection between your computer and the Router is fine, otherwise you'd not see this screen at all.


Solution (sometimes)
I checked the cables were all plugged in as usual. This is always an important first step.

Restart your Router. You can do this by switching off/on the Router using the physical switch. Or you can restart it by clicking the Diagnostic tab:


Click the Reboot Router button to restart the Router. This will take a few seconds, there is a count down, just be patient and let it finish. 

If it works then on the Overview tab you'll see:


However, if you don't, if you still see that red X then...


Still not working, try the Swisscom hotline?
After resetting my Router three times and I had waited more than 15 minutes, I phoned the Swisscom hotline 0800 800 800. After sometime pressing numbers to get through to a human being, the technician told me to switch off/on my Router! I explained (again) that I had already done that several times without success. I suggested it must be a problem with internet line from connecting to my home. The Swisscom technician then suggested I reset the configuration of my Router back to factory defaults!!!
I said "no, why, it was working yesterday!"
Then a moment later, the TV came on! I told him, there you go, your line is back up again! The Swisscom technician tried to come up with some explanation, I thanked him and put the phone down. Really he didn't help, I should've been more patient. Obviously Swisscom had a problem with the connection to my Router and that must've just come back on eventually. Maybe they were doing some work on it? We'll never know!


Conclusion
If the problem is just with the TV, switch off/on your TV box. It might just work normally...

If not then check your cables, make sure everything is plugged in.

If you have a similar problem to mine, switch off/on your Swisscom Router. If it still doesn't work, wait a few minutes. I would recommend you have a cup of tea, a biscuit, then maybe it'll just start on its own.

Don't reset or change your Swisscom configuration if it was working before. It makes no sense to do that. If it was working yesterday then why should it not work today? It could be something outside of your control. Of course always double check your cables, switch off/on your Router again to be sure.

This has happened to me a three or four times now. Each time just waiting seems to have been the solution. It's a real pain because we all rely upon the internet and our TV so much these days. But phoning Swisscom doesn't seem to help. They are very quick to suggest drastic and illogical measures. Enjoy your tea and biscuits, be patient!


6 Jul 2013

Excel 2010 - Compare two worksheets using Spreadsheet Compare


Introduction
I had two Excel files and I wanted to compare them to see the differences. Excel 2010 doesn't have a way to do this included. I had a look on the web and found a free add-in for Excel called Spreadsheet Compare.


Download and Install
You can download it here: http://sourceforge.net/projects/spreadshcompare/
Once it has downloaded open the EXE and follow the prompts to install.
After installation, when you start Excel the next time, click the Add-ins tab. You'll have a Compare button.


Using Spreadsheet Compare
Let's suppose you have two Excel files like this:


Make backup copies of the two worksheets you want to compare. This is important because Spreadsheet Compare will alter the worksheets you compare.

In Excel open the two worksheets you want to compare.

Click the Add-ins tab, click Compare.


Select the two worksheets - as you can see in my example above, my files are called Sheet1 and Sheet2.

Click Compare


When it's finished click OK


As you can see in the above, my Sheet1 and Sheet2 have highlights indicating the differences between the two files. The third worksheet explains in more detail. 


Conclusion
This add-in works! It does a good job and it's free, what more could you want?