eTOM – Telecom Business Process Framework

The adoption of the TM Forum’s Business Process Framework, also known as eTOM, continues to increase within the information, communications, and entertainment industry. As a result, a need has arisen to provide guidance the practical use of the framework and how the framework can be extended and/or modified for use.

TM Forum are therefore delighted to announce the launch of eTOM – A Business Process Framework Implementer’s Guide. The guide provides a review of the Business Process Framework, a typical implementation approach, a set of guidelines for extending the framework and a series of case studies for demonstrating uses of the framework.

Purpose of Standardizing Business process based on eTOM frame work:

  1. Provides a common process framework for telecom service providers
  2. Provides process and standard, holistic view across applications, functions and departments.
  3. Provides Starategy/Infrastructure/Product/Operations and enterprise management process
  4. Reflect the input and support of telecom service providers around the world.
  5. Guideline for design and development for business process
  6. Identify and analyze the cost of business process
  7. Develop a standard approach to business process design.

The eTOM model consists of Level-0, Level-1, Level-2 and Level-3 process. Each level drills down to the more specific processes.

ETOM

Strategy, Infrastructure & Product:

Columns

Strategy and Commit, Infrastructure Lifecycle Management and Product Lifecycle Management

Rows

Marketing & Offer Management, Service Development & Management, Resource Development & Management and Supply Chain Development & Management

Operations:

Columns

Operations Support & Readiness, Fulfillment, Assurance and Billing

Rows

Customer Relationship Management, Service Management & Operations, Resource Management & Operations and Supplier/Partner Relationship Management.

SAS DQ Tool

1. Who owns this product ? 

DataFlux is a leading provider of data quality (DQ) tools since 1997. Acquiring by SAS in 2000, they are operated as a separate subsidiary. Now its SAS add-in tool.

2. What is purpose of this tool ?

This tool used for Data Cleanse (Techniques for Merge/Purge on Very Large Datasets) purpose

Data cleansing(removing duplicates, etc), 

Data augmentation,

Data consolidation, 

Data verification

Data integration.

Data Quality – Cleanse : The SAS Data Quality – Cleanse add-in tools enable you to easily leverage the data quality solution as part of your SAS data warehouse. Use the three tools to define and manage schemes and match code definitions. The three add-in tools are:

The DQ – Scheme Loader, which enables you to refresh scheme data tables that have been imported into the warehouse using the DQ – Scheme Administrator add-in. The DQ – Scheme Loader takes advantage of extended attributes that are set on the load process of each scheme data table during the import process. 

The DQ – Scheme Administrator, which generates code for the SCHEME procedure. (The SCHEME procedure is available with SAS Data Quality – Cleanse Software.) The add-in allows you to create new schemes, import existing schemes, and apply schemes registered in the SCHEME VAULT data group. A scheme is a lookup table that contains clusters of similar data items where one item in the cluster is used as the standard for all the items in the cluster.

The DQ – Match Code Generator, which generates code for the MATCH procedure, which is available with SAS Data Quality – Cleanse. The MATCH procedure attempts to identify variations in data that result in data duplication, yielding a more accurate database. Based on match criteria that you specify, the DQ – Match Code Generator Add-in generates code that produces a match code for each observation and clusters observations with the same match code together. 

-Udhaya Kumar.V, Udhaya@udhaya.com

Architect Skills

IT Architect: The role of the IT architect is to solve a problem by defining a system that can be implemented using any type of the technology. The IT architect should keep it in mind about company vision while defining system. Architect will use domain knowledge, existing abstract, method, concepts and patterns to provide system. IT Architect thinking about Problem and Solution space, while defining system.

Main Architect Skills:

Domain Knowledge: This will help to understand problem domain. IT architect should have domain knowledge across the industry to understand problem/requirement. Even IT architect can use domain expert to understand the problem.

Conceptual: IT architect should have the capability to demonstrate solution in conceptual model. Technical and non-technical stakeholder can understand very well about the system using Conceptual System. Conceptual model is one of the IT Architect artifact which is every stakeholder can understand & it will be converted as functional requirement and components.

Patterns: IT architect should have the knowledge of existing domain and design patterns. This will help to come up with new proved system based on existing patterns. So we don’t have much risk while building new system for domain problem.

Technical: Technology growing every platform. As architect cant be a expert in every technology, but they should have the knowledge of the technology and use. It means IT Architect should have the knowledge of every technology use and advantages/disadvantages. Architect should know the technology solution and development/maintenance advantages.

By Udhaya Kumar.V, eMail Udhaya@Udhaya.com

How to get DNS server Name/IP stored in the local machine?

DNS server IP Under Unix:

cat /etc/resolv.conf.

IP under Windows XP/NT/2003
C:\>ipconfig /all

Linear SINGLE LINK LIST C Program Example

I am writing this single link list c program after very long time !!! One of my colleague asked me some of the sample program for link list. I though I can share this sample …

/* ======================== sll.h =====================*/

/*
** Description : Linear SINGLE LINK LIST example for learning.
**
** Author Name : Udhaya Kumar.V
**
** Created Date: 28-Sep-2006
**
** File Name : sll.h
**
** Copyrights : Any one can use for learning purpose.
*/

#ifndef _H_SLL
#define _H_SLL

typedef struct web
{
char url[ 256 ];
char ip[ 16 ];
struct web *Next;
}WEB;

WEB *Start, *Last, *Cur, *Prev;

int add_webpage( WEB *Rec ); /* To Add a node in Link List */
int lookup_webpage( char *url ); /* To Looup webpage record from Link List */
void display_webpage( void ); /* Display all webpage link list records */
int delete_webpage( char *url ); /* To delete webpage node from link list based on url */

#endif

/* ======================== sll.c ===================*/

/*
** Description : Linear SINGLE LINK LIST example for learning.
**
** Author Name : Udhaya Kumar.V
**
** Created Date: 28-Sep-2006
**
** File Name : sll.c
**
** Copyrights : Any one can use for learning purpose.
*/

#include
#include “sll.h”

/*
** Description: To add new node in WEB Link List.
**
** Return Value: 0 for Success, -1 for Failure
*/

int add_webpage( WEB *Rec )
{
/* allocate memory for current node */
if( ( Cur = (WEB *) malloc( sizeof( WEB ) ) ) == NULL )
return( -1 );

/* copy the structure to current node */
memcpy( Cur, Rec, sizeof( WEB ) );

/* adding first node */
if ( Start == NULL )
Start = Cur;
else
Last->Next = Cur;

Last = Cur;
Cur->Next = NULL;

return( 0 );
}

/*
** Description: To Looup webpage record from Link List.
**
** Return Value: 0 for Record found, -1 for Not found
*/

int lookup_webpage( char *url )
{
/* Loop will travel from first node to last node in Link List */
for( Cur = Start; Cur; Cur=Cur->Next )
{
if( !strcmp( Cur->url, url ) ) /* If record found */
return( 0 );
}

return( -1 ); /* If record not found */
}

/*
** Description: Display all webpage records from link list.
**
*/

void display_webpage( void )
{
for( Cur = Start; Cur; Cur=Cur->Next )
printf( “URL: %20s IP: %16s\n”, Cur->url, Cur->ip );
}

/*
** Description: To delete webpage node from link list based on url.
**
** Return Value: 0 for Record deleted successfully, -1 for Not found
*/

int delete_webpage( char *url )
{
WEB *Temp;

/* Loop will travel from first node to last node in Link List */
for( Cur = Start; Cur; Prev = Cur, Cur = Cur->Next )
{
/* find the node */
if( !strcmp( Cur->url, url ) )
{
Temp = Cur;
if( Cur == Start ) /* If first node */
{
Start = Temp->Next;
}
else if( Cur->Next == NULL ) /* If last node */
{
Prev->Next = NULL;
Last = Prev;
}
else /* If middle node */
{
Prev->Next = Cur->Next;
}
free( Temp );
return( 0 );
}
}
return( -1 );
}

main( void )
{
WEB web_site;
int input;

while( 1 )
{
printf( “\n1.Add Webpage 2.Display Webpages 3.Delete Webpage 4.exit – your choice: ” );
scanf( “%d”, &input );

switch( input )
{
case 1: /* 1.Add Webpage */
/* Get the url and ip value from user */
printf( “Enter URL and IP with space:” );
scanf( “%s%s”, web_site.url, web_site.ip );

if( lookup_webpage( web_site.url ) != 0 )
{
if( add_webpage( &web_site ) == 0 )
printf( “web_site record added successfully.\n” );
}
else
printf( “Given web site already exist in the Link List.\n” );

break;

case 2: /* 2.Display Webpages */
display_webpage();
break;
case 3: /* 3.Delete Webpage */
printf( “\nPlease enter URL to delete:” );
scanf( “%s”, web_site.url );

if( delete_webpage( web_site.url ) == 0 )
printf( “web_site record deleted from link list.\n” );
else
printf( “given url not found from Link List.\n” );

break;

case 4:
printf( “Bye .. I don.t know this program useful for u or not …\n” );
exit( 0 );

default:
printf( “Use proper option(1,2,3,4)\n” );
}
}
}

/* ======================== How To Compile ===============*/

$ cc sll.c -o webpage

/* ======================== How To Execute =============*/

$ webpage

1.Add Webpage 2.Display Webpages 3.Delete Webpage 4.exit – your choice: 1
Enter URL and IP with space:udhaya.com 10.12.12.12
web_site record added successfully.

1.Add Webpage 2.Display Webpages 3.Delete Webpage 4.exit – your choice: 1
Enter URL and IP with space:google.com 10.11.11.21
web_site record added successfully.

1.Add Webpage 2.Display Webpages 3.Delete Webpage 4.exit – your choice: 1
Enter URL and IP with space:udhaya.com 12.12.12.12
Given web site already exist in the Link List.

1.Add Webpage 2.Display Webpages 3.Delete Webpage 4.exit – your choice: 2
URL: udhaya.com IP: 10.12.12.12
URL: google.com IP: 10.11.11.21

1.Add Webpage 2.Display Webpages 3.Delete Webpage 4.exit – your choice: 3

Please enter URL to delete:google.com
web_site record deleted from link list.

1.Add Webpage 2.Display Webpages 3.Delete Webpage 4.exit – your choice: 2
URL: udhaya.com IP: 10.12.12.12

1.Add Webpage 2.Display Webpages 3.Delete Webpage 4.exit – your choice:

Tutorial for unix architecture & commands

 

Compiled By: Udhaya Kumar.V
Document   : Tutorial for Unix Architecture & Commands
Date       : April – 2004
Contact    : URL: http://www.udhaya.com , Mail Id: Udhaya@udhaya.com

 


Hai, This tutorial specking about Unix features, architecture, file system architecture, commands, vi editor, system administration and job scheduling. It’s very simple way of studying about Unix. I have compiled the information for beginners to Unix. This document not contains all the options of the command. It’s having very important commands and options.

What is operating system?

An operating system is the program that controls hardware and software. It’s providing the interface to access the hardware resource through the application. OS reduce the end user work for handling hardware. Basic work for OS is Process Management, Memory Management and IO handling.

History of Unix:

Unix was developed in AT&T Bell Labs. Dennis Ritchie and Ken Thompson released first version of UNIX. This version written in C language and some of the low level interaction written in assembly language.

Features of Unix

Portability: we can install the Unix for micro, mini and mainframe computers. Unix Os having hardware compatibility.

Modularity: we can modify the OS for our requirement, but it’s not affect the OS architecture and functionality. We can remove some of the unwanted functionality same as we can add more feature in existing OS itself.

Multi Process: At the same time we can run any number of the process under the processor. Virtually Unix running more then one process under one processor. This is handled based on round robin method.

Multi User: Unix system handle more then one user at the same time.

Security: Unix provides different type of the security. Like User level, file level, process level, memory level, hardware resource level. It’s provides the centralized security system.

Communication: Unix provides different type of the communication. Like mail, chat, wall messages.

Net Working: Unix provides some of the basic protocol to interact with external resource. Like TCP/IP, RPC, Telnet, etc

Open System: any external channel can interact with Unix through TCP/IP protocol. This is very basic interface for Unix.

Library: Unix provides development environment for different software. It’s provides some base libraries for development.

Unix Architecture

Unix is having Layered based architecture. It’s having three important layer 1. Kernel 2. Shell 3. Application & User

1.Kernel

This is the first layer in Unix System to interact with Hardware. It’s called as heart of the OS. Basic work of the kernel is process scheduling, memory managing and hardware interaction. Kernel can interact with the hardware through device drivers.

2.Shell

This is called as Command Interpreter. Interface between Kernel and User. Unix having different type of the Shell, every shell having unique feature.

3.User & Application

User interacts with the Unix system through Shell. All the application also running in this layer.

More About Shell

Whenever we login to a Unix system we are placed in a program called the shell. Because, every unix user id bind with any specific shell. Once successfully logged in the Unix System, we can get the prompt in the screen. Now our shell is ready for user interaction. Some of the prompt like $, %, #, etc

Several shells are available in UNIX. Some of the list

Bourne shell (sh).

C shell (csh).

TC shell (tcsh).

Korn shell (ksh).

Bourne Again SHell (bash).

We can switch between the different shells once we have found out if they are available.

Bourne shell (sh):

This is the original Unix shell written by Steve Bourne of Bell Labs. It is available on all UNIX systems.

This shell does not have the interactive facilities provided by modern shells such as the C shell and Korn shell.

The Bourne shell does provide an easy to use language with which you can write shell scripts.

C shell (csh):

This shell was written at the University of California, Berkeley.

It provides a C-like language with which to write shell scripts – hence its name.

Korn shell (ksh):

This shell was written by David Korn of Bell labs.

It is now provided as the standard shell on Unix systems. It provides all the features of the C and TC shells.

Bourne Again SHell (bash):

This is a public domain shell written by the Free Software Foundation under their GNU initiative.

This shell is widely used within the academic community. bash provides all the interactive features of the C shell (csh) and the Korn shell (ksh). Its programming language is compatible with the Bourne shell (sh).

UNIX file system

A file system is a logical method for organizing and storing large amounts of information in a way which makes it easy manage. The file is the smallest unit in which information is stored.

Structure of the File system.

The UNIX file system is organized as a hierarchy of Directories. Starting from a single directory called root which is represented by a / (slash). Imagine it as being similar to the root system of a plant or as an inverted tree structure. Immediately below the root directory are several system directories that contain information required by the operating system.

About File system Hierarchy:

/(root) – The directory located at the top of the Unix file system. It is represented by the “/” (forward slash) character.

/bin – This directory contains the commands and utilities that you use day to day. These are executable binary files.

/dev – This directory contains special files used to represent real physical devices such as printers and terminals.

/etc – This directory contains various commands and files which are used for system administration.

/lib – This directory contains libraries that are used by various programs and languages.

/tmp- This directory acts as a “scratch” area in which any user can store files on a temporary basis.

/usr – This directory contains system files and directories that you share with other users. Application programs, on-line manual pages, and language dictionaries typically reside here.

/home – This directory contains a home directory for each user of the system.

Standard File System

Unix system having some standard file systems, Every Unix system having this file system

Root File System

/bin, /etc, /dev, /lib

Boot File System

/stand, /unix

Swap File System

/swap

User File System

/home, /tmp, /var

File System Configuration Files

/etc/vfstab

Every file system contains one entry in this file. This file contain file system configuration information

/etc/mnttab

All the mounted file system information available in this file

/etc/default/fs

Default file system configuration information available in this file. Example: LOCAL=ufs

File System Layout

Boot Block:

This block Occupies the beginning(First sector) of a file system. It’s contains the Boot Strap code.

Super Block:

This Block Contains State of the file system, File Size, free spaces, number of inodes, number of disk blocks etc.

Inode Block:

This Block Contains List of inodes. The administrator specifies Inode List Size during configuration of the file system.

Data Block:

This Block Contain file and administrative data

Types of Files:

Ordinary files:

This is the type of file usually used to store the information, such as some text, image,etc. Any file is always contained within a directory.

Directories:

A directory is a file that holds other files and other directories.

Special files:

This type of file is used to represent a real physical device such as a printer, tape drive or terminal.

What Is a Process?

A program execution called as Process. Has a series of bytes that the CPU interprets as instruction, Kernel loads the executable file into memory

The loaded process contains 3 regions text, data and stack. Can run in 2 modes Kernel mode and User mode

About Processes

Each process created on the system has a unique number, known as its PID, associated with process. When you login to the system a process is started to run your shell program. New processes that are started from within your shell such as entering a command are the children of this process. A process can have many children, but only one parent. Kernel Process table contains process entries.

Some Basic Process List

Process Id 0 – Swapper, Scheduler process, system process

Process Id 1 – Init process, invoked by the kernel at the end of bootstrap procedure, never dies, normal user process.

Process Id 2 – page daemon process (on virtual memory implementation), kernel process, support paging of virtual memory.

How will log in System?

Using telnet protocol, we can communicate with Unix system. Example telnet <ip/hostname>. We get the “login:” prompt for enter the login, after get the “password:” prompt, we have to enter password.

After successful log in to the system, user placed in home directory. Shell initializes the environment variable for every user. this information configured by user using profile file.

Some Environment Variable

PATH = The search path for shell commands

TERM = The terminal type (sh and csh)

DISPLAY = X11 – the name of your display

LD_LIBRARY_PATH = Path to search for object and shared libraries

HOST = Name of this unix host

PRINTER = Default printer (lpr)

HOME = The path to your home directory (sh)

SHELL = Default Shell

TZ = Time Zone

Set the environment variable using commands

env = provides current shell environment variable list

$env

export = update the environment variable in current shell

$ export PS1=“Hai ..”

$ export PATH=$PATH:/usr/oracle/bin:

$ export SHELL=/usr/bin/sh:

unset = delete the environment variable from shell list

$unset MYPATH

We can change the environment setting using special file. This files is referred by shell at the startup time. This startup file is differed based on the shell type. Default this special file is available in user home directory.

Some of the special file follows

C Shell = .cshrc

Bourne Shell = .profile

Korn Shell = .profile

BASH = .bashrc

Some of the Shell name follows

sh = Bourne shell

csh = C shell

tcsh = TC shell

ksh = Korn shell

bash = Bourne Again Shell

Login Process:

“getty” is a process for assign the terminal to the login requester. Login and Password verified by “login” process. Login process referred “/etc/passwd” for user verification and “/etc/shadow” for password verification. Once this “Login” process is succeed then corresponding shell is invoked. Now shell is set the environment for user based on special file (.profile). After that user get the prompt to work.

About Unix Process

Daemon Process

  • Process that executes in the background and is not associated with terminal and login shell.
  • Waiting for an event to occur or waiting to perform some specified task on a periodic basis for eg, line printer daemon, remote login daemon, crontab
  • Start up of daemon process during system startup, from crontab, using at, from a user

Zombie Process

  • Scenarios to be considered in processes, Child process terminates before the parent process (or) Parent process terminates before it child process
  • Zombie process is one that has terminated, but its parent process has not waited for it yet.
  • The kernel releases all the resources being used by the zombie process, but has to atleast maintain its exit status, until its parent waits for it.

Orphan Process

What happens to the child process when the parent process terminates before the child process?

  • Parent process ID of the child process becomes invalid
  • Parent process ID is assigned to 1 (init Process ID)
  • init process becomes the parent process of any orphaned process
  • init process never terminates
  • child process will not be aware of its PPID change

Unix Basic Commands

Command syntax rules

cp [-iprR] filename … directory.

  • Any options or arguments enclosed in [] square brackets are optional.
  • Anything not enclosed in [] square brackets must be entered.
  • Arguments shown in italics must be replaced by whatever it is that they represent. This is usually the name of a file or directory.
  • Ellipses ‘…’ mean that the previous argument can be repeated any number of times.

Online Manual Command

$man cp

-The command “man” gives you access to an on-line manual containing a complete description of every command available on this system.

$man –k keyword

-Gives the manual based on the keyword

Locating Commands

which – Locate a command path and display its pathname or alias

$ which cd

cd: shell built-in command.

$ which cp

/bin/cp

type – write a description of command type

$ type cd

cd is a shell builtin

Switch Between User

su – If you have more than one account on the system and want to switch to the other user use command

$ su username

-You are still in the same working directory you were when you issued the command, but you now have access to the file system for your other account. To stop using this account enters the command exit.

Short hand for home directories

- The (~) tilde character can be used to refer home directories. Eg. cd ~/arun takes us to arun home directory. Paths can also be specified in this fashion.

pwd – Command to display the Present Working Directory

$ pwd

/home/helper

$su projX

Password: (password for account projX)

$whoami (command to display the username)

projX

cd – Command to Change Directory . A cd without and parameters takes you to the home

$cd c

System identity Commands

uname – Display system name and operating system release.

-a Prints basic information currently available from the system.

-i Prints the name of the hardware implementation (plat- form).

-X Prints expanded system information, one information

hostname – Show the name of this host.

domainname - Show the name of the local NIS domain.

tty - return user’s terminal name

ifconfig – configure network interface parameters.

-a Apply the commands to all interfaces in the system

Show other users logged on

finger – Show who is logged onto this and other systems.

who – List of users logged into this system.

w – Long list of who is logged onto this system and what they are doing.

Handling Files

mkdir <dir name> – make directories

rmdir <dir name> - remove directory entries

cat <filename> – concatenate and display files

cp <source> <Target> – copy files

-r copy the directory and all its files, including any subdirectories and their files to target.

-i Interactive. cp will prompt for confirmation

mv <source> <target> – move files

-f mv will move the file(s) without prompting

-i mv will prompt for confirmation

more – browse or page through a text file

rm – Remove directory or file

-r Recursively remove directories and subdirectories

List the files

ls – list contents of directory

-a Lists all entries, including those that begin with a dot (.), which are normally not listed.

-F Marks directories with a trailing slash (/),

-i For each file, prints the i-node number in the first column of the report.

-l Lists in long format,

-R Recursively lists subdirectories encountered.

-t Sorts by time stamp (latest first) instead of by name.

-r Reverses the order of sort to get reverse alphabetic

-x Multi-column output with entries sorted across rather than down the page.

Granting Access Permission

Every file and directory in your account can be protected from or made accessible to other users by changing its access permissions To display the access permissions of a file or directory use the command:

$ ls -l file1

-rw-r–r– 2 unixjohn doc 3287 Apr 8 12:10 file1

There are three types of permissions:

r read the file or directory.

w write to the file or directory.

x execute the file or search the directory.

Each of these permissions can be set for any one of three types of user:

u the user who owns the file (usually you)

g members of the group to which the owner belongs

o all other users

The access permissions for all three types of user can be given as a string of nine characters:

User group others

r w x r w x r w x.

chmod mode filename – Changing access permissions

chmod mode directory_name.

+ add the specified permission.

- subtract the specified permission.

= assign the specified permission, ignoring whatever may have been set before.

To give yourself permission to execute a file that you own:

chmod u+x file1

To give members of your group permission to read a file:

chmod g+r file2

To give read permission to everyone for a particular type of file:

chmod a+r *.file

To give the group write and execute permission

chmod g+wx $HOME/FILE

chown [ -fhR ] owner [ : group ] file … – change file ownership

chgrp [ -fhR ] group file … - change file group ownership

Important Keys

CTRL-S

Stops scrolling of screen output

CTRL-q

Resumes scrolling of screen output

CTRL-U

Kill command line without executing it

CTRL-C

Interrupt or break key. Sends signal 15 to a process.

CTRL-D

Terminates Login Session (exit)

CTRL-Z

Suspend the present process, but do not destroy it.

CTRL-J

CTRL-M

Alternative to enter

Redirection Operator

> redirect out put

$ cat > file1 , > file2

$ cat file1 2> error > logfile

>> append out put to file

$cat file1 >> file2

< redirect input

$ wc < file1

| Pipe Out Put

$ who | wc –l

tee replicate the standard output

$ who | tee users

& run process in background

$ pop3.sh &

Wild Card Characters

`?‘ – Match single character.

e.g. ls /etc/rc.????

`*’ – Match any number of characters.

e.g. ls /etc/rc.*

`[...]‘ – Match any character in a list enclosed by these brackets.

e.g. ls [abc].C

[!nnn] – matches any character that is not enclosed.

[n-m] - matches any character in this range.

Miscellaneous Commands

date – Print the date and time.

bc – Text-based calculators.

cal – display a calendar.

touch – Creates an empty new file if none exists, or updates date and time stamps on existing files.

file <File name>

lp, lpr – Line printer. Send a file to the default printer, or the printer defined in the `PRINTER’ evironment variable.

lpq, lpstat – Show the status of the print queue.

Alias Commands

alias dele=’rm -i.‘

alias l=‘ls –al’

dele memo.txt

$ alias aliasname – To check what command is aliases to an alias name type

$ alias - To list all aliases type

$ unalias aliasname – To remove alias use command

Communication Commands

write – Send a simple message to the named user, end with CTRL-D. The command `mesg n’ switches off messages receipt.

talk – Interactive two-way conversation with named user.

mail – The standard (old) mail interface.

$ mailx -s “Test mail“ unix@in.efunds.com

TEst msg

.

EOT

wall – write to all users

Disk Usage

du - summarize disk usage

-k Write the files sizes in units of 1024 bytes, rather than the default 512-byte units.

-s Instead of the default output, report only the total sum for each of the specified files.

df - displays number of free disk blocks and files

-a Report on all file systems including

-b Print the total number of kilobytes free

-e Print only the number of files free

-v complete set of file system specific command lines

Process Commands

ps – report process status

-a Lists information about all processes most frequently requested

-f Generates a full listing

-e Lists information about every process now running

-l Generates a long listing.

$ ps –ef

$ ps –el

kill – terminate or signal processes

Kill <signal> <pid>

$kill –9 1020 # kill the 1020 pid process

$kill –9 0 # Kill all process including the login shell

System Statistics Commands

vmstat – List kernel virtual-memory statistics

$vmstat

netstat – List network connections and statistics

$netstat -a

rpcinfo – Show rpc information

$rpcinfo

showmount – Show clients mounting local file systems

$showmount

ipcs – inter-process communication report

$ipcs

ipcrm – remove a message queue, semaphore , shared memory

ping – send ECHO_REQUEST packets to network hosts

$ ping India.com

No Hang Up command

nohup – run a command immune to hang ups

nohup sh [file]

$ nohup ComServer & #nohup.out the output file

$ nohup ComServer comlog & #comlog is the out file

History Commands

history – process command history list

hash – evaluate the internal hash table of the contents of directories

last – display login and logout information about users and terminals

Line, Word, Character count Commands

wc – command counts the number of words, characters and lines in a file. By using a different option you can choose what is counted.

wc -w file1 counts the words.

wc -c file1 counts the characters.

wc -l file1 counts the lines.

Link Commands

Hard link

ln <source File> <Target File> – Hard links

$ ln systemlog log

Symbolic Link (Soft Link)

ln –s <source> <Target> – Soft links

$ ln –s systemlog /nformix/log/sys

Cut & Transfer Commands

cut – cut out selected fields of each line of a file

cut -c list [ file ... ]

cut -f list [ -d delim ]

$cut –d”|” –f2 emp.dat

tr – translate characters

tr [options] expression1 expression2

-s replace single character

$ ps -ef | tr -s ” “

$ ps -ef | tr -s ” ” | cut -d ” ” –f3

Head & Tail Commands

head – display first few lines of files

head [ -number ] [ filename ...]

$head file1 $head -5 file1

tail – deliver the last part of a file

tail [ +- number ] [ file ]

-f Follow

$tail -5 syslog #last 5 lines

$tail +5 syslog #start with 5 th line to EOF

$tail -f syslog #monitor the growth of the file

Editor – vi – Text Editor

Syntax: “vi filename”

$ vi <file Name> # open the given file

$ vi +<Line Number> <File Name> #open the given file and place the cursor in given line Number.

Commands

a – Insert text after the cursor

i - Insert text before the cursor

A – Append text at the end of the current line

I – Insert text at the start of the current line

o - Open a new line below the current line

O - Open a new line above the current line

Saving and Quitting

ZZ or :wq – To quit and save the contents of the buffer to the file

:q – quit

:q! – quit without saving the contents of the buffer to the file

:w filename – Save the contents of the buffer to a new file

Cutting and Pasting

yy – yanks the current line into the buffer.

p – places the yanked text after the current cursor position.

Delete Text

x – to delete the current character.

dd - to delete the current line.

dw - to delete the current word.

d$ - to delete till end of line from cursor.

d0 - to delete till beginning of line from cursor.

5dw – deletes the current word and the following four words.

Searching Text

Press <ESC>

“/pattern” – to forward search for a pattern

“?pattern” – to backward search for a pattern

“n” to repeat last search

“N” to repeat last search backward

Command Line

:g/pattern1/s//pattern2/g replace all occurrences of pattern1 with pattern2

:1,100 s/pattern1/pattern2/g for line 1 to 100, substitute pattern1 for pattern2

:1,$ s/pattern1/pattern2/g for all lines substitute pattern1 for pattern2

:10,20d delete lines 10 through 20

:10,20y yank lines 10 through 20 to the buffers

:1,5p display 1 through 5 lines

:20 cursor got to 20 the line

Navigation

h – Cursor Left, l – cursor Right, k – up, j – down

b – back word wise, w – forward word wise

<Ctrl-f> Scrolls full page forward

<Ctrl-b> Scrolls full page back word

<Ctrl-d> Scrolls half page forward

<Ctrl-u> Scrolls half page backward

.exrc file configuration

set showmode # see the mode

set shownumber # see the number

set ts=2 # set the tab space

map #1 :!cc % # map the F1 key

abbr inc #include <stdio.h> # add abbreviation

Regular Expression

`.’ Match any single character except the end of line.

`^‘ Match the beginning of a line as the first character.

`$’ Match end of line as last character.

`[..]‘ Match any character in the list between the square brackets

`*’ Match zero or more occurrences of the preceding expression.

`+‘ Match one or more occurrences of the preceding expression.

`?’ Match zero or one occurrence of the preceding expression.

[...] matches any of the enclosed characters

[^...] matches any character that is not enclosed

[n-n] matches any character in this range

* matches any number of the preceding character

Search Commands

grep [-bchilnsvw ] limited-regular-expression [ filename ... ]

-l Print only the names of files with matching lines

-v Print all lines except those that contain the pat-tern.

-n Precede each line by its line number in the file

$ls -l | grep ‘^d……..x.‘

lists all the directories in the current directory for which other users have execute permission.

$ls -l | grep ‘[^.xdh]$.‘

lists all the files and directories in the current directory which do not end in .xdh.

$grep –n “sys” serverlog

find – find a files

find path … Expression

-name pattern select file filename

-atime n the file’s data was accessed n days ago

-mtime -n the file’s data was modified les then n days

-print current path name to be printed

-type c type of the file is c, [b, c, d, f, l, p, or s ]

-links n True if the file has n links.

-size n[c] the size is in bytes

-exec command execute unix command

-ok command Like –exec. Ask confirmation

$find . -name ‘*.fm’ -print -searching using wild cards. Quotes is mandatory

$find ./ -size +1024 -print

$find /usr/local -name gnu -type d –print -searching for a directory

$find $HOME \( -name a.out -o -name ‘*. \) \ -atime +7 -exec rm {} \;

$find . -name SCCS -print

Sort Command

sort filename.

sort +2 -3 names - This sorts the file names on the third word of each line).

sort -o results +3 -5 scores - sorts on words 4 and then on 5

-d (Dictionary order) sort only uses numbers, letters and blank spaces when sorting the file.

-f (Fold in lower case) sort treats all lower-case letters as if they were upper-case letters.

-i (Ignore non-printing characters) sort ignores any characters that do not print.

-n (Numeric order) sort recognizes the value of numbers and sorts them in terms of their value.

-r (Reverse order) sort reverses its default sort order.

-t option to specify another character to act as the field delimiter.

Different & Unique command

diff – command can be used to compare two files.

diff -iw part1 part_one

-iw – makes it ignore case and also white spaces.

uniq - Unique To remove duplicate lines from a file

uniq in_file out_file.

Compress Utility

compress <option> <File Name> – Compress the file

$ compress comserver.tar

uncompress <File Name> – Uncompress the file

$uncopress comserver.tar.Z

zcat <File Name> – display the compressed file content

$zcat comserver.Z

pack, pcat, unpack – compress and expand files

pack file …

pcat file …

unpack file …

Pack the file

$pack comserver

Unpack the file

$unpack comserver.z

display the compressed file content

$pcat comserver.z

tar - Tape Archive Command

tar – create tape archives and add or extract files

tar [options] [file]

c -creates a new tape.

r -append files to a tape.

t -print the names of files if they are stored on the tape.

x -extract files from tape.

Options:

f – uses path name.

b n – use blocking factor of n.

l – print error messages about links not found.

v - list file in long format ( verobse option )

w - confirm from user for any action.

$tar cvf server.tar server1.txt server2.txt

$tar cvf server.tar servre_dir

$tar xvf server.tar

$tar cvf /dev/rdsk/f0q18dt /home/informix #taking backup

$tar xvf /dev/rdsk/f0q18dt #restore the file

$tar tvf /dev/rdsk/f0q18dt #Display archive

$tar uf /dev/rdsk/f0q18dt ./query.sql #Append archive

$tar xvwf /dev/rdsk/f0q18dt ./query.sh #interactive

/etc/default/tar #device identify KEY

$tar cv6 server_code

$tar xv6

Formatting floppy diskettes

format & fdformat # format the floppy default

$format #SCO Unix, etc

$fdformat #Linux

Handling DOS Diskettes

$dosformat a: #dos format

$doscp ip.dat a:

$dosdir a: # List files

$dosrm a:ip.dat # Remove ip.dat from floppy

$dosmkdir a:bin # Create directory in Floppy

$dosrmdir a:bin # delete directory from floppy

$mcopy ip.dat /dev/fd0H1440:/ip.dat #Linux

File System Command

fdisk – create or modify fixed disk partition table

mkfs – construct a file system

$ mkfs –F minix /dev/sdb2

fsck – check and repair file systems

fsck <Device>

$ fsck /dev/vx/dsk/source

mount, umount – mount or unmount file systems

mount [-F FSType] <Device> <mount_point>

$ mount /dev/fd0 /mnt

umount <mount_point>

$ umount /mnt

mountall, umountall – mount, unmount multiple file systems

$ mountall

$ umountall

Running Jobs Periodically

The ‘cron’ command starts a process that executes commands at specified dates and times. Regularly scheduled commands can be specified according to instructions found in crontab files in the directory /var/spool/cron/crontabs. Users can submit their own crontab file using the crontab command. /etc/cron.d is main cron directory.

Crontab Entry Format, A crontab file consists of lines of six fields each. Spaces or tabs separate the fields.

minute (0-59),

hour (0-23),

day of the month (1-31),

month of the year (1-12),

day of the week (0-6 with 0=Sunday),

-e - Edit crontab file

-l - list the crontab file for the invoking user

-r - remove a user’s crontab from the crontab directory.

$crontab crontabfile # submit the job to cron

$crontab –l # list the current crontab entries

$crontab –r #delete your file

$crontab –r username #delete any user crontab file

Cron Samples

15 4 * * * /usr/local/bin/geterror > /usr/log/geterror.log 2>&1

0 1 * * * /usr/local/bin/log > /usr/log/log.err 2>&1

0 3 * * 0 /usr/local/bin/clientlogs.sh > /dev/null 2>&1

0 3 * * * /usr/local/bin/batch.sh /usr/local/bin/batch_param

15 3 * * 1-5 find $HOME -name core 2>/dev/null | xargs rm -f

User Admin

useradd – administer a new user login on the system

-c comment

-d dir The home directory of the new user.

-g group existing group’s integer ID or character-string name.

-s shell Full pathname of the program used as the user’s shell.

-u uid The UID of the new user

$useradd –d /home/user1 –g dba –c “Informix” –s /bin/ksh user1

usermod – modify a user’s login information on the system

$usermod –s /bin/sh user1

userdel – delete a user’s login from the system

$userdel user1

Internet Daemon

inetd, inetd.conf – internet “super-server”

Configuration FILES

/etc/inetd.conf configuration file for all inetd provided services

# <service_name> <socket_type> <proto> <flags> <user> <server_pathname> <args>

/etc/services service name to protocol and port number mapping

/etc/protocols protocol name to protocol number mappings

/etc/rpc Sun-RPC service name to service number mappings.

Default RPC Services

rlogin – remote login

rsh – remote shell

rcmd - routines for returning a stream to a remote command

rcp – remote file copy

 


Driver Compilation & Installation in SunOS 5.8

 

<!–[if !vml]–><!–[endif]–> 

Hai, Just I am sharing some of the information about SunOs Driver Installation.

Written By Udhaya Kumar.V

9 August 2002

Contact:  udhaya@udhaya.com

URL    : www.udhaya.com

<!–[if !vml]–><!–[endif]–><!–[if !supportEmptyParas]–> <!–[endif]–>

Driver Compilation & Installation in SunOS 5.8

<!–[if !supportEmptyParas]–> <!–[endif]–>

Hai, I am used some of the commands for SunOs Stream Driver Manipulation and Installation.

<!–[if !supportEmptyParas]–> <!–[endif]–>

How will find the sunOS Kernel Type (32-Bit / 64-Bit OS Kernel)?

#isainfo -v

64 bit – sparcv9 application.

>

32 bit – sparc applications.

Note: if System Running in the 64-bit operating system, it’s give this output.

#isainfo -v

32 bit – sparc applications.

Note: if System Running in the 32-bit operating system, it’s give this output.

<!–[endif]–>

#isainfo -v

32 bit i386 applications.

Note: In the x86 system, it’s give this output.

How will compile the programme For 32-bit or 64 bit ?

If 32-bit Kernel

cc -O -o mx12n mx12n.c

If 64-bit Kernel

cc -xarch=v9 -O -o mx12n mx12n.c

Compilation Environment in SunOs

__sparc     => This is include SPARC v7, SPARC v8 and SPARC v9

__sparcv8   => This is 32-Bit SPARC V8.

__sparcv9   => This is 64-Bit SPARC V9.

__i386      => This is intel 386, Pentium 386 and 486

<!–[endif]–>

Where we want to copy the Driver files?

For 32-bit Kernel, Driver File copied to.

/usr/kernel/drv

For 64-bit Kernel, Driver File copied to.

/usr/kernel/drv/sparcv9

Where we want to copy the Driver Configuration File?

All the configuration files should be in.

/usr/kernel/drv/

Every driver should have one Configuration file, File name is Driver Name and extension is “.conf

For example:

Driver Name is “ttype” then configuration file name is “ttype.conf”

<!–[if !supportEmptyParas]–>

some of the commands, i am used for my driver manipulation

add_drv – Add the device driver to system>

rem_drv – Remove the Device Driver From System<

modload – Load a Kernel Module

>

modunload – Unload the Module

prtconf – Print the System Configuration<

drvconfig – For Configure the /device Directory

modinfo – Display the information about Loded Kernell Module

autopush – Configured List of the modules to be Pusheed.

crash – Examins System Memory Images.

strchg – Prtints STREAMS trace message

strconf- Changes or Queries on Stream Configuration

strerr – Logs Streams Error

strace – Display the message from Specific Stream LLog

isalist – List the Native Instruction Set>

Debug Tool-Device Driver

adb

kadb

crash

<!–[endif]–> geovisit();

OS/2 Drivers Configuration

Slave Proxy Server ( Source Code in SCO Unix )

Written by Udhaya Kumar.V
20 – April – 2001
http://www.udhaya.com
Conduct Id : udhaya@udhaya.com

Slave Proxy Server ( Source Code in SCO Unix )

ProxyServer.cpp

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#define        USER_IP_LIST                “/pserver/ip.dat”
#define        USER_ERROR                “/pserver/error.html”
#define        BUFSIZE                    1024

class TCPServer
{
private:
struct sockaddr_in            ServerAddress;
struct sockaddr_in            ClientAddress;
struct sockaddr_in            ProxyAddress;
int                     ServerSocket;
int                     ProxySock;
int                    Client;
int                    ProxyHandle;
int                    BrowserHandle;
int                     MaxFdp;
int                     NFound;
int                     NRead;
char                     Data[ BUFSIZE ];
char                    ErrorData[ 2048 ];
fd_set                    ReadMask;
struct timeval                 TimeDelay;

struct Handle
{
int                BHandle;
int                PHandle;
struct Handle            *HNext;
}*HStart, *HLast, *HCur, *HPrev;

struct IpAddress
{
char                Ip[ 15 ];
struct IpAddress        *INext;
} *IStart, *ILast, *ICur;

public:

TCPServer( char Address[ 15 ],int PortNo );
~TCPServer () {}
int                    CreateServer( void );
int                    ServerListen ( int BackLog );
int                    ServerAccept ( void );
void                    DataHandle ( void );
void                    AddHandle ( int Bh, int Ph );
void                    DeleteHandle ( int Bh, int Ph );
void                    DisplayHandle ( void );
void                    GetIp ( void );
int                    ExistIp ( char    Ip[ 15 ] );
void                    GetErrorMessage ( void );
};

TCPServer :: TCPServer( char Address[ 15 ], int PortNo )
{
HStart = HLast = NULL;
IStart = ILast = NULL;
ServerAddress.sin_family = AF_INET;
ServerAddress.sin_port = htons ( PortNo );
ServerAddress.sin_addr.s_addr = inet_addr ( Address );
bzero ( &ServerAddress.sin_zero, 8 );

ProxyAddress.sin_family = AF_INET;
ProxyAddress.sin_port = htons ( 81 );
ProxyAddress.sin_addr.s_addr = INADDR_ANY;
bzero ( &ProxyAddress.sin_zero, 8 );

TimeDelay.tv_sec = 0;
TimeDelay.tv_usec = 1;
}

int TCPServer :: CreateServer( void )
{
GetIp ();
GetErrorMessage ();
if ( ( ServerSocket = socket ( AF_INET, SOCK_STREAM, 0 ) ) < 0 )
{
perror ( “Socket Error.” );
exit ( 0 );
}
else
{
if ( bind ( ServerSocket, (struct sockaddr * ) &ServerAddress,16 )<0 )
{
perror ( “Bind Error.” );
exit ( 0 );
}
else
printf ( “Proxy Server Started(Bind).\n” );
}
return ( ServerSocket );
}

int TCPServer :: ServerListen ( int BackLog )
{
int Ret;
if ( ( Ret = listen ( ServerSocket, BackLog ) ) < 0 )
{
perror ( “Listen Error:” );
exit ( 0 );
}
else
printf ( “(Listen).\n” );
return ( Ret );
}

int TCPServer :: ServerAccept ( void )
{
if ( ( BrowserHandle = accept ( ServerSocket , (struct sockaddr *) &ClientAddress, &Client ) ) < 0 )
{
perror ( “Browser connection error:” );
exit ( 0 );
}
else
{
if ( ( ProxyHandle = socket ( AF_INET, SOCK_STREAM, 0 ) ) < 0 )
{
printf ( “Socket Error.\n” );
exit ( 0 );
}
if ( connect ( ProxyHandle, ( struct sockaddr * ) &ProxyAddress, sizeof(ProxyAddress) ) < 0 )
{
perror ( “Proxy Connection Error:” );
exit (2);
}
else
{
AddHandle ( BrowserHandle, ProxyHandle );
}
}
return ( BrowserHandle );
}

void TCPServer :: AddHandle ( int Bh, int Ph )
{
HCur = ( struct Handle * ) malloc ( sizeof ( struct Handle ) );
HCur->BHandle = Bh;
HCur->PHandle = Ph;

if ( HStart == NULL )
HStart = HCur;
else
HLast->HNext = HCur;
HLast = HCur;
HCur->HNext = NULL;
}

void TCPServer :: DeleteHandle ( int Bh, int Ph )
{
struct Handle *Temp;
for ( HCur = HStart; HCur; HPrev = HCur, HCur = HCur->HNext )
{
if ( HCur->BHandle == Bh && HCur->PHandle == Ph )
{
Temp = HCur;
if ( HCur == HStart )
{
HStart = Temp->HNext;
}
else if ( HCur->HNext == NULL )
{
HPrev->HNext = NULL;
HLast = HPrev;
}
else
{
HPrev->HNext = HCur->HNext;
}
free ( Temp );
}
}
}

void TCPServer :: DisplayHandle ( void )
{
for ( HCur = HStart; HCur; HCur=HCur->HNext )
printf ( “BHandle: %d  PHandle: %d\n”, HCur->BHandle, HCur->PHandle );
}

void TCPServer :: GetIp ( void )
{
FILE        *Fp;
char        ip[ 15 ];

Fp = fopen ( USER_IP_LIST, “r” );
if ( Fp == NULL )
{
printf ( “%s File Not Found \n”, USER_IP_LIST );
printf ( “Please enter the browser ip address information” );
exit ( 0 );
}
else
{
while ( 1 )
{
fscanf ( Fp, “%s”, ip );
printf ( “\nAccess Ip: %s”, ip );
ICur = ( struct IpAddress * ) malloc ( sizeof ( struct IpAddress ) );
strcpy ( ICur->Ip, ip );
if ( IStart == NULL )
IStart = ICur;
else
ILast->INext = ICur;

ILast = ICur;
ICur->INext = NULL;

if ( feof ( Fp ) )
break;
}
}
fclose ( Fp );
}

int TCPServer :: ExistIp ( char    Ip[ 15 ] )
{
for ( ICur = IStart; ICur; ICur=ICur->INext )
if ( strcmp ( ICur->Ip, Ip ) == 0 )
return ( 1 );
return ( 0 );
}

void TCPServer :: GetErrorMessage ( void )
{
FILE        *Fp;
char        Dat[ BUFSIZE ];

Fp = fopen ( USER_ERROR, “r” );
if ( Fp == NULL )
{
printf ( “Please create error file( %s ) \n”, USER_ERROR );
printf ( “After U can start Proxy Server\n” );
exit ( 0 );
}
else
{
while ( !feof ( Fp ) )
{
fgets ( Dat, ‘\n’, Fp );
strcat ( ErrorData, Dat );
}
}
fclose ( Fp );
}

void TCPServer :: DataHandle ( void )
{
while ( 1 )
{
FD_ZERO ( &ReadMask );
FD_SET ( ServerSocket, &ReadMask );
for ( HCur = HStart; HCur; HCur = HCur->HNext )
{
FD_SET ( HCur->BHandle, &ReadMask );
FD_SET ( HCur->PHandle, &ReadMask );
MaxFdp = HCur->PHandle;
}
MaxFdp++ ;

NFound = select ( MaxFdp, &ReadMask, ( fd_set *) 0, ( fd_set * ) 0, ( struct timeval * ) &TimeDelay );

if ( NFound < 0 )
{
perror ( “Select Error:” );
}

if ( FD_ISSET ( ServerSocket, &ReadMask ) )
{
if ( ( BrowserHandle = accept ( ServerSocket , (struct sockaddr *) &ClientAddress, &Client ) ) < 0 )
perror ( “Browser connection error:” );
else
{
int d = sizeof ( ClientAddress );
getpeername ( BrowserHandle, (struct sockaddr * )&ClientAddress, &d );
if ( ExistIp ( inet_ntoa ( ClientAddress.sin_addr ) ) == 1 )
{
if ( ( ProxyHandle = socket ( AF_INET, SOCK_STREAM, 0 ) ) < 0 )
printf ( “Socket Error.\n” );
if ( connect ( ProxyHandle, ( struct sockaddr * ) &ProxyAddress, sizeof(ProxyAddress) ) < 0 )
{
perror ( “Proxy Connection Error:” );
exit (2);
}
else
{
AddHandle ( BrowserHandle, ProxyHandle );
}
}
else
{
sprintf ( Data, “HTTP/1.0 302 Found\nContent-type: text/html\nContent-length: %d\n\n”, strlen ( ErrorData ) );
write ( BrowserHandle, &Data, strlen ( Data ) );
write ( BrowserHandle, &ErrorData, strlen ( ErrorData ) );
strcpy ( Data, “\n\n” );
write ( BrowserHandle, &Data, strlen ( Data ) );
}
}
}

for ( HCur = HStart; HCur; HCur = HCur->HNext )
{
if ( FD_ISSET ( HCur->BHandle, &ReadMask ) )
{
NRead = read ( HCur->BHandle, &Data, sizeof ( Data ) );
if ( NRead <= 0 )
{
close ( HCur->BHandle );
close ( HCur->PHandle );
DeleteHandle ( HCur->BHandle, HCur->PHandle );
break;
}
if ( write ( HCur->PHandle, &Data, NRead ) != NRead )
printf ( “\nError:- Write Error to Stream pipe” );
}
}

for ( HCur = HStart; HCur; HCur = HCur->HNext )
{
if ( FD_ISSET ( HCur->PHandle, &ReadMask ) )
{
NRead = read ( HCur->PHandle, &Data, sizeof ( Data ) );
if ( NRead <= 0 )
{
close ( HCur->BHandle );
close ( HCur->PHandle );
DeleteHandle ( HCur->BHandle, HCur->PHandle );
break;
}
if ( write ( HCur->BHandle, &Data, NRead ) != NRead )
printf ( “\nWrite error in stdout” );
}
}
}
}

main ()
{
TCPServer *Server = new TCPServer ( “140.0.0.178″, 80 );
Server->CreateServer ();
Server->ServerListen( 20 );
Server->DataHandle ();
}

/pserver/ip.dat

140.0.0.70
140.0.0.71
140.0.0.72
140.0.0.73
140.0.0.76
140.0.0.77
140.0.0.80
140.0.0.50
140.0.0.30

/pserver/error.html

Sorry, U don’t have permission to access this Proxy Server.

Any suggestions or problems regarding this web site should be directed to udhaya@udhaya.com
Copyright © 2001-2003 V.Udhaya Kumar . All rights reserved. Last updated 02-04-20001

Web Server Source Code ( SCO Unix )

Written by Udhaya Kumar.V
20 - April - 2001
http://www.udhaya.com
Conduct Id : udhaya@udhaya.com


Written by Udhaya Kumar.V
20 – April – 2001
http://www.udhaya.com
Conduct Id : haiudhaya@yahoo.com

Web Server Source Code( SCO Unix )

makefile

WebServer : WebServer.o
CC -g WebServer.o -lsocket -o WebServer
strip WebServer
mcs -d WebServer

WebServer.o : WebServer.cpp WebServer.hpp WebServer.dpp
cp WebServer.cpp WebServer.C
CC -g -c WebServer.C
rm WebServer.C

WebServer.hpp

class TCPServer
{
private:
struct sockaddr_in ServerAddress;
struct sockaddr_in ClientAddress;
int Server;
int Client;
int ServerHandle;
int ServerPort;
char Data[ SIZE ],buff[ 25 ];
char FileName[30];
char FilePath[100];
char FileType[6];
int IsDirectory;
int IsExist;
int FileSize;
char Method[10];
char ContentType[50];

public:

TCPServer( int PortNo );
~TCPServer () {}
int CreateServer( void );
int ServerListen ( int BackLog );
int ServerAccept ( void );
void DataSend ( void );
void DataRecieve ( void );

private :

void GetPath ( void );
void GenerateHomePage ( void );
void SendFile ( void );
void GetFileType ( void );
void GetContentType ( void );
};

WebServer.dpp

#define DEFAULT_PATH “/usr/udhaya/WWWroot”
#define DEFAULT_FILE “Default.html”

#define HTML “html”
#define HTM “htm”
#define TEXT “txt”
#define JPG “jpg”
#define JPEG “jpeg”
#define PJPEG “pjpeg”
#define GIF “gif”
#define XBITMAP “x-xbitmap”
#define PNG “png”
#define BMP “bmp”

#define CDIR “.”
#define PDIR “..”

#define SIZE 1024

WebServer.cpp

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include <dirent.h>
#include <ctype.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#include “WebServer.dpp”
#include “WebServer.hpp”

TCPServer :: TCPServer( int PortNo )
{
ServerAddress.sin_family = AF_INET;
ServerAddress.sin_port = htons ( PortNo );
ServerAddress.sin_addr.s_addr = INADDR_ANY;
bzero ( &ServerAddress.sin_zero, 8 );

strcpy ( FilePath, DEFAULT_PATH );
IsDirectory = 0;
IsExist = 0;
FileSize = 0;
}

int TCPServer :: CreateServer( void )
{
if ( ( Server = socket ( AF_INET, SOCK_STREAM, 0 ) ) < 0 )
printf ( “\nSocket Error.” );
else
{
if ( bind ( Server, (struct sockaddr * ) &ServerAddress,16 )<0 )
printf ( “\nBind Error.” );
}
return ( Server );
}

int TCPServer :: ServerListen ( int BackLog )
{
int Ret;
if ( ( Ret = listen ( Server, BackLog ) ) < 0 )
perror ( “Listen Error:” );
return ( Ret );
}

int TCPServer :: ServerAccept ( void )
{
if ( ( ServerHandle = accept ( Server , (struct sockaddr *) &ClientAddress, &Client ) ) < 0 )
perror ( “Accept Error :” );
return ( ServerHandle );
}

void TCPServer :: DataSend ( void )
{
char Str[ SIZE ];
char s[ SIZE ];

if ( IsExist == 1 ) /* File Is Exist */
SendFile();
else /* File Not Found */
{
char Error[ SIZE ]=”<html< <body bgcolor=lightgreen><h1< Given File Not Found <p< Please Enter proper path </p< </h1< </body< </html<”;
sprintf ( s, “HTTP/1.0 302 Found\nServer: NCSA/1.3\nMIME-version: 1.0\nContent-type: text/html\nContent-length: %d\nLocation: http://udhaya%s\n\n”, strlen ( Error ), FileName );
write ( ServerHandle, s, strlen ( s ) );
write ( ServerHandle, Error, strlen(Error) );
write ( ServerHandle, “\n\n”, strlen(“\n\n”) );
}
}

void TCPServer :: DataRecieve ( void )
{
memset ( Data, 0, sizeof(Data) );
if ( read ( ServerHandle, Data, sizeof ( Data ) ) <= 0 )
{
close ( Client );
exit ( 1 ) ;
}
else
GetPath();
}

void TCPServer :: GetPath ( void )
{
int i=0,j=0,Tag=0;
char Word[ SIZE ];
int Cnt=1;
struct stat FileStat;

memset ( FileName, ”, 30 );
for ( i=0; Data[i]!=”; i++ )
{
Word[j]=Data[i];
j++;
if ( Data[i] == ‘ ‘ && Tag == 0 )
{
Tag=1; j=0;
Word[j]=”;
strcpy ( Method, Word );
memset ( Word, ”, SIZE );
}
else if ( Data[i] == ‘ ‘ && Tag == 1 )
{
Word[j]=”;
strcpy ( FileName, Word );
for ( j=0; j<=30; j++)
{
if ( FileName[j] == ‘ ‘ )
FileName[j]=”;
}
break;
}
}
strcpy ( FilePath, DEFAULT_PATH );
strcat ( FilePath, FileName );

/* Find File Type */

lstat( (const char * ) FilePath, &FileStat );
if ( S_ISDIR ( FileStat.st_mode ) )
{
IsDirectory = 1;
if ( strcmp ( FileName , “/” ) == 0)
strcat ( FilePath, DEFAULT_FILE );
else
{
strcat ( FilePath, “/” );
strcat ( FilePath, DEFAULT_FILE );
}
}
else
IsDirectory = 0;

/* Find File */
if ( ( access ( FilePath, F_OK ) ) < 0 )
IsExist = 0;
else
IsExist = 1;

/* Find File Size */
FileSize = ( int ) FileStat.st_size;

/* Get File type … Only extension */
GetFileType ();

if ( IsDirectory == 1 )
IsExist = 1;

/*Generate Default.html for Directory */
if ( IsExist == 1 && IsDirectory == 1 )
{
strcpy ( FileType, HTML );
GenerateHomePage ();
}
}

void TCPServer :: GenerateHomePage ( void )
{
FILE *Fp;
char File[30];
char Fpath[100];
char Dpath[100];
DIR *dirp;
int Cnt=1;
struct dirent *dp;
struct stat FileStat;

if ( IsDirectory == 1 )
{
if ( FilePath[ strlen(FilePath) - 1 ] == ‘/’ )
FilePath[ strlen(FilePath) - 1 ] = ”;
strcpy ( File, FilePath );
Fp = fopen ( File, “w” );
if ( strcmp ( FileName, “/” ) == 0 )
{
fputs( “<html> <body bgcolor=lightgreen> <center> <h1> Hai Welcome to Document World… </h1> <h2> TCP/IP, UDP, Socket, RPC …..</h2> </center>”, Fp );
}
else
{
fputs( “<html> <body bgcolor=lightgreen> <center> <h1> Document List .</h1> <h2> You can select any document…</h2> </center>”, Fp );
}

strcpy ( Dpath, FilePath );
Dpath[ strlen ( FilePath ) - 12 ] =”;

dirp = opendir ( Dpath );
fputs ( “\n<table border = 1 width=100%> <tr> <TD width=75%> Document Name </TD> <TD width=25%> Document Size </TD>”, Fp );

while ( ( dp = readdir ( dirp ) ) != NULL )
{
if ( ( strcmp ( dp->d_name, CDIR ) != 0 ) && ( strcmp ( dp->d_name, PDIR ) != 0 ) && ( strcmp ( dp->d_name, DEFAULT_FILE ) != 0 ) )
{
sprintf ( Fpath, “%s/%s”, Dpath, dp->d_name );
lstat( (const char * ) Fpath, &FileStat );
fprintf ( Fp, “\n<TR> <TD> <a href=http://udhaya/%s> %d %s </a> </TD> <TD>%d </TD> </TR>”, dp->d_name, Cnt, dp->d_name, FileStat.st_size );
Cnt++;
}
}
fputs ( “\n</table> </body> </html>”, Fp );
fclose ( Fp );

lstat( (const char * ) FilePath, &FileStat );
FileSize = (int) FileStat.st_size;
}
}

void TCPServer :: SendFile ( void )
{
FILE *Fp;
int bfp;
char Str[ SIZE ];
char s[ SIZE ];
int i;

for ( i=0; i<=30; i++)
if ( FilePath[i] == ‘ ‘ )
FilePath[i]=”;

GetContentType (); /* Gent The content type value */

if ( strcmp ( FileType, GIF ) == 0 || strcmp ( FileType, XBITMAP ) == 0 || strcmp ( FileType, JPEG ) == 0 || strcmp ( FileType, PJPEG ) == 0 || strcmp ( FileType, PNG ) == 0 || strcmp ( FileType, BMP ) == 0 || strcmp ( FileType, JPG ) == 0 )
{
long Dat;
bfp = open ( FilePath, O_RDONLY );
sprintf ( s, “HTTP/1.0 302 Found\nServer: NCSA/1.3\nMIME-version: 1.0\nContent-type: %s\nContent-length: %Ld\nLocation: http://udhaya%s\n\n”, ContentType, FileSize, FileName );
write ( ServerHandle, s, strlen ( s ) );

while ( read ( bfp, &Dat, SIZE) )
{
if ( write ( ServerHandle, &Dat, SIZE ) < 0 )
perror ( “Error Write :” );
}
close ( bfp );
write ( ServerHandle, “\n\n”, strlen(“\n\n”) );
}
else
{
Fp = fopen ( FilePath, “r” );
sprintf ( s, “HTTP/1.0 302 Found\nServer: NCSA/1.3\nMIME-version: 1.0\nContent-type: %s\nContent-length: %Ld\nLocation: http://udhaya%s\n\n”, ContentType, FileSize, FileName );
write ( ServerHandle, s, strlen ( s ) );
while ( !feof(Fp) )
{
fgets ( Str, SIZE, Fp );
if ( write ( ServerHandle, Str, strlen(Str) ) < 0 )
perror ( “Error Write :” );
}
write ( ServerHandle, “\n\n”, strlen(“\n\n”) );
fclose ( Fp );
}
}

void TCPServer :: GetFileType ( void )
{
int i,j=0,Tag=0;

memset ( FileType, ”, 8 );
if ( strlen ( FileName ) > 1 )
{
for ( i=0; FileName[i]!=”; i++ )
{
if ( Tag == 1 )
{
FileType[j]=FileName[i];
j++;
}
if ( FileName[i] == ‘.’ )
Tag=1;
}
FileType[j]=”;
if ( strlen ( FileType ) == 0 )
strcpy ( FileType, HTML );

for ( i=0; FileType[i] != ”; i++ )
FileType[i] = tolower ( FileType[i] );

if ( strcmp ( FileType, HTM ) == 0 )
strcpy ( FileType, HTML );
}
}

void TCPServer :: GetContentType ( void )
{
if ( strcmp ( FileType, HTML ) == 0 || strcmp ( FileType, HTM ) == 0 )
strcpy ( ContentType, “text/html” );
else if ( strcmp ( FileType, TEXT ) == 0 )
strcpy ( ContentType, “text/plain” );
else if ( strcmp ( FileType, JPG ) == 0 )
strcpy ( ContentType, “image/jpeg” );
else if ( strcmp ( FileType, GIF ) == 0 || strcmp ( FileType, XBITMAP ) == 0 || strcmp ( FileType, JPEG ) == 0 || strcmp ( FileType, PJPEG ) == 0 || strcmp ( FileType, PNG ) == 0 || strcmp ( FileType, BMP ) == 0 )
{
strcpy ( ContentType, “image/” );
strcat ( ContentType, FileType );
}
else
strcpy ( ContentType, “text/plain” );
}

main ()
{
char *Str;
int SHandle;
int Cid;

TCPServer *Server = new TCPServer ( 80 );
Server->CreateServer ();
Server->ServerListen( 5 );

while ( 1 )
{
Str = ( char * ) malloc ( SIZE );
SHandle = Server->ServerAccept ();
Cid = fork ();
if ( Cid == 0 )
{
Server->DataRecieve ();
Server->DataSend ();
close ( SHandle );
_exit ( 0 );
}
}
}

Any suggestions or problems regarding this web site should be directed to udhaya@udhaya.com
Copyright © 2001-2003 V.Udhaya Kumar . All rights reserved. Last updated 02-04-20001