Saturday, December 13, 2008

andLinux --- Run Linux from Windows

Have you ever had a feeling of using Linux when you are working on Windows???
Or
Felt like using those very useful Linux commands fromWindows???

This is possible ...

Everybody knows that you can have a Dual-Boot on your PC with Linux & Windows. In which you have to restart the PC to access the other OS. 

But there are several other ways to have Other OS run right from Windows, that is for example use Linux when you have logged on to Windows... Yes... Virtual Machines (also popular as VM) is one of them. But running a VM requires that your hardware to be really good.

There is one more option, we now have emulated PC software like andLinux.

There are many other softwares other than andLinux, such as CygwinX, MKS Toolkit, etc
But I found andLinux to be really very handy, straight-forward & useful.

Installing andLinux is as simple as installing other software ... clikcing Next, Next, Next ... & finnaly Finish :) there is a very elaborate tutorial on its web site

However if you are the curious cat... you can also fiddle around & do the installation without the tutorial.

The home page of andLinux says "andLinux is not just for development and runs almost all Linux applications without modification". I have installed a lot many applications to andLinux, and its really true.

After installation you can see the icons of andLinux in system tray. You may see these icons :
KDE menu (andLinux)
Xming (andLinux)

While installing say you choose E: drive as destination. It gets installled in a folder E:\andLinux.

It will create some folders & files in E:\andLinux, I will list some folders & files with thier purposes:
1. settings.txt, a plain-text file that will have some paths necessary for andLinux to work properly
2. srvstart.bat, batch file, that has the command to start the andLinux service
3. srvstop.bat, batch file, has the command to stop andLinux service
4. startup.bat, again a batch file used to start the andLinux as deamon
5. Drives, directory, where the andLinux's filesystem is stored as files (base.drv, mine is 4GB in size and swap.drv)
6. Launcher, directory, where all the executables can be seen. A good place to check out what all linux apps you get after installing andLinux.
7. There are other directories as well, netdriver, pulseaudio & Xming

One application that is very usefull after installing andLinux is the synaptic. It is the application manager of andLinux. You can find this from KDE Menu / open a terminal & type synaptic.

There is a huge collection of linux applications that you can select & install. As i feel the GUI is staright-forward & easy to understand, compared to CygwinX. It is more responsive on my machine with 512 MB of RAM & Dual Core Intel.

It is still in Beta, you can go to the andLinux website to download it. There is a torrent tracker also.

EnJoy ...

Friday, December 12, 2008

Script to comment parts of code in a source file

A friend of mine wanted a script to comment parts of code in a source file. We were chatting & i gave him this solution:

me: perl --i.bak -pe 's/^(.*)$/#$1/gi if ($. >=start_line_number && $. <= end_line_number)' filename
Try above command in terminal. Where start_line_number is the line number where u shud start commenting & end_line_number is where u want to stop commenting.

But he wanted that the script should take a function name as input rather than line numbers ... this is what he says: (name not published ;))

myfrend: hey vikas, i need a script to start commenting the codes without using line numbers, but using function name....is it possible?
me: u mean to say u have function names ... & u want to comment the whole functions?
u mean to say u have function names ... & u want to comment the whole functions?
myfrend: yeah
s
me: it is possible ... if u can get correct start&end boundaries for the functions
myfrend: yeah..how to get it....its difficult
me: how big can the file be .. that is MAX big file size?
myfrend: say around 3000 lines

I was asking a lot of questions about the source files like do they follow coding standards, etc .. & all that. So he suggested what he wanted to do ... i mean the logic ... he said:

myfrend: my logic is : search for function name, then keep a counter to increment/decrement when { or } is found, when counter is zero, exit the prgm
me: this is holds good ... but u have to account for { } occuring on same line ... & account for comments, etc
myfrend: ok

Got some free time to think about it ... & wrote a script for this. This may not be a complete solution, but a good starting point i guess.

Here is the link to the script:

PS - myfrend :
If you permit I can publish your name ... with a hyperlink possibly to your blog ;)