Thursday, June 30, 2011

Installation of Apache Web Server on Windows


Installation of Apache Web Server ( on Windows )

http://httpd.apache.org/docs/1.3/windows.html
Speed read 1. Requirements once, go to
"Download Apache for Windows"
Read this paragraph that starts like
"You should download the binary build of Apache for Windows named as
apache_1_3_#-win32-src.msi " once.
Click on link "http://httpd.apache.org



 





Click on "Download" above, another window opens up, Click on 2.2.19 as
shown below


Install it on your laptop or desktop and select the default location ( or
wherever you like ) or in my case "Program Files" "Apache Software
Foundation " "Apache 2.2"


Once done with the installation...
Start -> Apache 2.2 -> Control Apache Server -> Start Apache in Console.
A new windows console opens up, leave it as is.


Now,
cd "....<Apache.....> htdocs"folder from windows.
create a file called index.html

X------- Cut and Paste ------- index.html --X----------
<html>
<body>
It works again and again
</body>
</html>
X----------X--------- End Cut and Paste ----X---
Open the browser and type this URL
http://localhost/ it should show you this page

 

If you are able to see this - it means you installed the web server on your
server ! Congratulations.
Test another file.
create a file testinput.html

-X------ Cut and Paste -------------- testinput.html ---------X------


save and in the URL http://localhost/testinput.html should show this
page.












If you go this far, you can now write scripting in perl/PHP and render themon the page.
Now, go to http://www.w3schools.com/html/html_forms.asp and follow the
other tutorials.

Good Luck .

Monday, June 27, 2011

Installing perl in cygwin.

Bash should be installed by default,

If not - go up to this Installation Page and follow the instructions below.

(Embedded image moved to file: pic31791.gif)

To install bash, Check the very first line - it says 'it is installed'.
then do not have to install it.
else, select the first one and install it.


(Embedded image moved to file: pic30016.gif)

To Install Perl.

Click on the Perl Link in the first snapshot and install it.

Shashi

Friday, June 24, 2011

Valuable Bash Scripting Guide - Easy to learn


http://tldp.org/LDP/abs/html/


Very good link, If you are learning Bash, click on each link and see the examples ( and try it out )

Click on Part 1: Basics ,
Click on 3. Special Characters and see the examples.
Likewise go thru each chapter.


Thursday, June 23, 2011

some basic unix commands.

uname - will tell what version of OS it is running

"ps -ef " will tell the processes running on the server.

ps -ef |cut -c 10-17 will cut the output and get me just the process id.


Now, read what is the process id ?


ps -ef | awk '{print $1}' - this will give the first column in the ps -ef
command.

Likewise
ps -ef |grep '{print $2}' will display the 2nd column.

and so on.

What is the difference between
ps -ef |cut -c30-36

and

ps -ef |cut -c30-


What does the ping do ?

ping will try to talk to the remote server and check if it is alive or
not ?

what does the route command do ?

route PRINT - will list the routers etc,

where are the binaries in cygwin located ?

/usr/bin folder

Linux in a Nutshell



linux in a nutshell

Or

Read it online by clicking the link below - 6th edition here. ( you have to register I think )

http://my.safaribooksonline.com/9780596806088?portal=oreilly&cid=orm-cat-readnow-9780596806088


Tuesday, June 21, 2011

Basic Vi Commands,and some perl samples.

VI;
Good link to learn vi.

http://www.cs.colostate.edu/helpdocs/vi.html

Lists all the basic commands required to edit in VI on the Cygwin
environment.

Perl :
A simple perl script:

$> vi first.pl
#!/usr/bin/perl

print "hello world";

(Embedded image moved to file: pic01821.gif)

- Save and Exit
- Give it execute permissions - chmod 755 first.pl
- Check the permissions

(Embedded image moved to file: pic19172.gif)

- Execute it
./first.pl

(Embedded image moved to file: pic07581.gif)


Similarly, try this - this prints the string 10 times

for ( 1.. 10 ) {
printf (" hello world" );
}

Monday, June 20, 2011

How to delete an item in a perl array.

delete ($keys[$index] ) - does not really delete - it just sets it to
undef.


So, use splice - line 859 below .

Here, I have a list of 5 elements ( 866) , and I want to randomize it, so I
will call randomize_array () and this returns a randomized array.

839 sub randomize_array {
840
841 my @keys = @_;
842
843 my @new_array = ();
844
845 while ( 1 ) {
846
847
848 my $len = scalar ( @keys) ;
849
850 if ( $len == 0 ) { last; }
851
852 my $k= int rand( scalar(@keys));
853 #printf ( "rand is $k, value = $keys[$k] ");
854
855 push ( @new_array, $keys[$k] );
856
857 #delete ( $keys[$k] );
858
859 splice ( @keys, $k, 1 );
860
861 }
862 printf ("new array = [@new_array], size = %d\n", scalar
(@new_array));
863 return @new_array;
864 }
865
866 my @array = ( "5","10","15","25","35");
867
868 printf ( "old array = @array" );
869 printf ("\n");
870 printf ( scalar (@array) );
871
872 my @newarray = &randomize_array ( @array );
873
874 printf ( "new array = @newarray" );
875
876 " look at http://www.perlmonks.org/?node_id=1871"

Wednesday, June 15, 2011

Basic Unix commands

In windows create a folder called Downloads ( e.g : C:\Downloads)
Open a cygwin window and cd to this folder. ( write down what was the
command


>echo "hello world " > a.dat ( tell me what happened , and what is this
command )
>echo "hello world" >> a.dat ( tell me what happened )
- How do you copy the file a.dat to b.dat ( which command did you use )
- How do you delete the file b.dat ( which command did you
use )
- cd to root directory ? ( list the command here , how did you go to the
root directory ?)
- type " ls " ( list what happens , what are the files it showed up ?)
- cd to the Downloads folder you created above ?
- cd to the root again ?
- type in cd - ( cd dash ) what happens ? where does it go ?
- Create a directory called "src", and "dst" in the Downloads folder
( what was the command )
- cd to src directory and can you see the file contents ?


Go to windows explorer and see that the files are present.

Tuesday, June 14, 2011

Install Perl - the same way "VIM" was installed.

Perl is a scripting language - fast in processing and easy to learn and
quite flexible to handle data parsing and once you get used to it - you
will not be able to substitute it with any other tool.

Functions in Bash

#/usr/bin/bash

function myfunc()
{
myresult='some value'
}

# Call it with arguments and $1 will be the first argument.
function somefunc ()
{
echo "called function with argument $1"
}

myfunc

# functions that takes arguments
somefunc Sam
somefunc Ram

echo $myresult

exit 0

Monday, June 13, 2011

Bash Scripting exercise

Write a simple bash script that will read the files in the directory
( e.g: /tmp or c:\Downloads ) and then only files that end with ".txt"
will be renamed to ".txt.orig"

Tuesday, June 7, 2011

Checking if you got a notification on google.

Unix Scripting - bash scripts and initializing bash during startup.

Bash is a scripting language and also is  provided as a base application
from which the user can use tools like the vi editor, check on process,
navigate folders etc etc.
Here, I will write about simple tips and tricks to get maximum use of the
bash scripts.



Contents of .bash_history



 .bash_profile : this is a hidden file in the user's home directory, and is the first script to get executed automatically when you launch the"xterm" or the terminal.
To view the contents of this file ( as this is a hidden file - you'd have to type in ls -al ( a - yel )
A sample .bash_profile that I have configured is shown below, You will see that I have exported some environment variables like CVSROOT and CDPATH.

export CVSROOT="some value" will mean that this variable's value is visible
when the user types in echo $CVSROOT.
CDPATH is another variable that helps the UNIX user a lot. e.g: if there are 3 folders directories in /cygdrive/c/Downloads called "A", "B" and "C", the user would have to type in cd /cygdrive/c/Downloads/A , or
cd /cygdrive/c/Downloads/B, and similarly to navigate to C, he/she would
cd /cygdrive/c/Downloads/C
But, with the CDPATH="/cygdrive/c/Downloads", the user has to just enter "cd A" or "cd B" and "cd C", the OS would automatically prepend the /cygdrive/c/Downloads. This saves a lot of typing.


Experiment that by setting it to your favorite directory and you have to
reinitialize the .bash_history by executing it again by
typing . ./bash_history ( <dot> <space> <dot-slash> )
and now cd to your favorite directory and create 3 folders A, B, and C.
and now type in "cd A". you will notice that the control goes to the A
folder without the need to enter the full path.
Similarly check out "PATH", and "alias" commands that can be put into this
file.
Troubleshooting tips.
-Check that you executed the .bash_profile after editing. If not - close
this window - open a new window and see that this line gets executed.
- echo $CDPATH, to check that the variable is updated.
- insert a echo "hello world" in the beginning to see that this file gets
called during startup.

Exercise :
How do you see that when the user types in "ls", it should execute "ls
-l" i.e the long format.
Your new application is a new folder /cygdrive/c/Downloads/FavFolder, and you should be able to cd to /cygdrive/c and when you type in cd FavFolder - the control should automatically go to /cygdrive/c/Downloads/FavFolder.

Friday, June 3, 2011

Setting up Mail2 Blogger , posting your emails to blog page directly




Easy and Convenient steps to post your EMAILs to BLOG PAGEs, directly

1. Open the blogger.com and go to Settings -> Email and Mobile.



2. Now, go to "Posting Options", and enter a secret word, ( See
pic ) I entered my secret word. You could enter your own secret word
and send an email to this address, where it will post your EMAIL to BLOG
directly.
e.g: kiranshashi.blogpage@blogger.com
Note: I used the secret keyword blogpage



3. Check on 'Publish emails immediately'    and    "Save Settings"


4. Go back to your favorite email tool like Lotus Notes, Yahoo, or Hotmail
etc and send emails.

e.g: I sent an email to kiranshashi.blogpage@blogger.com and it will
post it to my blogpage.
In your case, you will change the name appropriately to your blog id, and send an email.
This should show up as a new post in your blog page.

Please do not hesitate to contact me at kiranshashiny@gmail.com, if you are not fully satisfied with the notes above.

Thursday, June 2, 2011

Installing VIM in CYGWIN - Part 1

This blog tells you how to install VI editor in Cygwin.
Typically, the base/default  installs of Cygwin does not install the VI editor. One has to either reinstall this editor or choose to install during the initial installation.

To check if vi is installed or not, first open a xterm cygwin window and type in "vi", If this fails as shown below , then follow the instructions listed in this page.

 

Run setup.exe of cygwin.



sdfsdfds


Choose the appropriate selection.




Next,


 Next



Click Next,




Next,


Click Next,





Here, you will be presented the list of applications and their install states. And most, are by default not installed. Here you will click on Editors and choose VIM.





The default above will change to install,













The VIM package will start downloading. After this is done - one can open the cygwin window and type in vi, and start using the editor.


Installing VIM in Cygwin