A Unix shell, also called "the command line", provides the traditional user interface for the Unix operating system and for Unix-like systems. Users direct the operation of the computer by entering command input as text for a shell to execute. Within the Microsoft Windows suite of operating systems the analogous program is command.com, or cmd.exe for Windows NT-based operating systems.
The most generic sense of the term shell means any program that users use to type commands. Since in the Unix operating system users can select which shell they want to use (which program should execute when they login), many shells have been developed. It is called a "shell" because it hides the details of the underlying operating system behind the shell's interface (in contrast with the "kernel", which refers to the lowest-level, or 'inner-most' component of an operating system). Similarly, graphical user interfaces for Unix, such as GNOME, KDE, and Xfce can be called visual shells or graphical shells. By itself, the term shell is usually associated with the command line. In Unix, any program can be the user's shell. Users who want to use a different syntax for typing commands can specify a different program as their shell.
The term shell also refers to a particular program, such as the Bourne shell, sh. The Bourne shell was the shell used in early versions of Unix and became a de facto standard; every Unix-like system has at least one shell compatible with the Bourne shell. The Bourne shell program is located in the Unix file hierarchy at /bin/sh. On some systems, such as BSD, /bin/sh is a Bourne shell or equivalent, but on other systems such as Linux, /bin/sh is likely to be a link to a compatible, but more feature-rich shell(like Bash shell). POSIX specifies its standard shell as a strict subset of the Korn shell.
You can use any one of these shells if they are available on your system. And you can switch between the different shells once you have found out if they are available -
.
Different Shells
1. Bourne shell (sh)
2. C shell (csh)
3. TC shell (tcsh)
4. Korn shell (ksh)
5. Bourne Again SHell (bash)
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 facilites provided by modern shells such as the C shell and
Korn shell
You are advised to to use another shell which has these features.
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, Berkley. It provides a C-like language with which to write shell scripts- hence its name.
TC shell (tcsh)
This shell is available in the public domain. It provides all the features of the C shell together with emacs style editing of the command line.
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 together with a shell programming language similar to that of the original Bourne shell. It is the most efficient shell. Consider using this as your standard interactive shell.
Bourne Again Shell (bash)
This is a public domain shell written by the Free Software Foundation under their GNU initiative. Ultimately it is intended to be a full implementation of the IEEE Posix Shell and Tools specification. This shell is widely used within the academic commnity. 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). If you use the Bourne shell (sh) for shell programming consider using bash as your complete shell environment.
Summary of shell facilities
--------------------------Bourne C TC Korn BASH
________________________________________________________
command history - No Yes Yes Yes Yes
command alias - No Yes Yes Yes Yes
shell scripts - Yes Yes Yes Yes Yes
filename completion - No Yes* Yes Yes* Yes
command line editing - No No Yes Yes* Yes
job control - No Yes Yes Yes Yes
________________________________________________________
* not the default setting for this shell
Details:
The sh utility is a sophisticated shell (command interpreter) that offers, depending on the options chosen, compatibility with the Korn, Bourne-Again, and POSIX shells available on many UNIX systems. You can use it as a replacement for the standard Windows command interpreter (cmd.exe)
When invoked with the sh name, sh is primarily a POSIX.2 compatible shell with some selected Korn and Bourne-Again shell behavior.
resh is a restricted version of that shell and is equivalent to sh -r. For more information on the restricted shell, see the description of the -r option. Regardless of how it is launched, this reference page uses resh to refer to the restricted shell.
ksh is a version of the shell that uses, by default, standard Korn behavior when it may conflict with bash or MKS KornShell behavior. ksh is equivalent to running sh with the -K or -o korn options. Regardless of how it is launched, this reference page uses ksh to refer to the shell operating in KornShell mode.
Bash(Bourne-Again Shell) is the shell, or command language interpreter, that will appear in the GNU operating system. Bash is an sh-compatible shell that incorporates useful features from the Korn shell (ksh) and C shell (csh).
Accessing AWK variables in SHELL Script: Using “eval”
eval `echo $* awk -F: '{printf("a=%s; b=%s; c=%s\n", $1, $2, $3)}'`
print $a
print $b
print $c
Accessing SHELL variables in AWK Script
1.Protect the shell variables from awk by enclosing them with "'" (i.e. double quote - single quote - double quote).
awk '{print "'"$VAR1"'", "'"$VAR2"'"}' input_file
2. Use the -v switch to assign the shell variables to awk variables. This works with nawk, but not with all flavours of awk. On my system (Solaris 2.6) -v cannot be used with /usr/bin/awk but will work with /usr/xpg4/bin/awk.
nawk -v v1=$VAR1 -v v2=$VAR2 '{print v1, v2}' input_file
Links:
Advanced Bash-Scripting Guide -
http://www.faqs.org/docs/abs/HTML/index.htmlhttp://tldp.org/LDP/abs/html/
Unix Shell Scripting - http://cfaj.freeshell.org/shell/
Bash Shell Guide - www.gnu.org/software/bash/manual/
Unix Shells - http://www.ussg.iu.edu/usail/external/recommended/diffshell.html
Effective AWK programming - http://www.gnu.org/manual/gawk/gawk.pdf
Manipulating Strings : Shell Scripts -
http://www.faqs.org/docs/abs/HTML/string-manipulation.html
Linux Shell Scripting Tutorial v1.05r3 - A Beginner's handbook - http://www.cyberciti.biz/nixcraft/linux/docs/uniqlinuxfeatures/lsst/
Awk, Sed & grep - http://www.securitydocs.com/pdf/3489.PDF
Awk & Sed - http://unix.ittoolbox.com/topics/t.asp?t=429&p=429&h1=429#
Accessing AWK variables from Shell -
http://www.unix.com/shell-programming-scripting/32384-access-awk-variables-outside-scope.html
Accessing Shell Variables from AWK -
http://www.tek-tips.com/faqs.cfm?fid=1281
Search this Blog:
Unix Shell Scripts
.Net Programming Introduction
.NET Framework
The .NET Framework is the infrastructure for the new Microsoft .NET Platform.
The .NET Framework is a common environment for building, deploying, and running Web Services and Web Applications.
The .NET Framework contains common class libraries - like ADO.NET, ASP.NET and Windows Forms - to provide advanced standard services that can be integrated into a variety of computer systems.
The .NET Framework is language neutral. Currently it supports C++, C#, Visual Basic, JScript (The Microsoft version of JavaScript) and COBOL. Third-party languages - like Eiffel, Perl, Python, Smalltalk, and others - will also be available for building future .NET Framework applications.
The new Visual Studio.NET is a common development environment for the new .NET Framework. It provides a feature-rich application execution environment, simplified development and easy integration between a number of different development languages.
.NET Internet Standards
.NET is built on the following Internet standards:
HTTP, the communication protocol between Internet Applications
XML, the format for exchanging data between Internet Applications
SOAP, the standard format for requesting Web Services
UDDI, the standard to search and discover Web Services
Major Components of .NET
The .NET framework can only be exploited by languages that are compliant with .NET. Most of Microsoft languages have been made to fully comply with .NET.
.NET also introduces Web Forms, Web Services and Windows Forms, WPF,WCF,WF. The reason why they have been shown separately and not as a part of a particular language is that these technologies can be used by any .NET compliant language. For example Windows Forms is used by VC, VB.NET, C# all as a mode of providing GUI.
The next component of .NET is the .NET Framework Base Classes. These are the common class libraries that can be used by any .NET compliant language. These classes provide the programmers with a high degree of functionality that they can use in their programs. For example their are classes to handle reading, writing and manipulating XML documents, enhanced ADOs etc.
The bottom most layer is the CLR - the common runtime language.
What is "Common Language Specification" (CLS)
One of the obvious themes of .NET is unification and interoperability between various programming languages. In order to achieve this; certain rules must be laid and all the languages must follow these rules. In other words we can not have languages running around creating their own extensions and their own fancy new data types. CLS is the collection of the rules and constraints that every language (that seeks to achieve .NET compatibility) must follow.
Microsoft have defined three level of CLS compatibility/compliance. The goals and objectives of each compliance level has been set aside.
What is "Common Language Runtime" (CLR)
CLR is .NET equivalent of Java Virtual Machine (JVM). It is the runtime that converts a MSIL code into the host machine language code, which is then executed appropriately.
What is "Microsoft Intermediate Language" (MSIL)
A .NET programming language (C#, VB.NET, J# etc.) does not compile into executable code; instead it compiles into an intermediate code called Microsoft Intermediate Language (MSIL). As a programmer one need not worry about the syntax of MSIL - since our source code in automatically converted to MSIL. Complete specifications of MSIL can be found at http://msdn.microsoft.com/net/ecma/part_3_IL_inst_set.pdf .
The MSIL code is then send to the CLR (Common Language Runtime) that converts the code to machine language which is then run on the host machine[7]. MSIL is similar to Java Byte code. A Java program is compiled into Java Byte code (the .class file) by a Java compiler, the class file is then sent to JVM which converts it into the host machine language.
What is "Common Type System" (CTS)
All this time we have been talking about language interoperability, and .NET Class Framework. None of this is possible without all the language sharing the same data types. What this means is that an int should mean the same in VB, VC++, C# and all other .NET compliant languages. Same goes for all the other data types.
This is achieved through introduction of Common Type System (CTS). CTS, much like Java, defines every data type as a Class. Every .NET compliant language must stick to this definition. Since CTS defines every data type as a class; this means that only Object-Oriented (or Object-Based) languages can achieve .NET compliance.
The .NET Compilation Stages
The Code written in .NET isn't compiled directly to the executable, instead .NET uses two steps to compile the code.
First, the code is compiled to an Intermediate Language called Microsoft Intermediate Language (MSIL).
Second, the compiled code will be recompiled with the Common Language Runtime ( CLR ), which converts the code to the machine code.
The basic Idea of this two stages was to make the code language independence.
MSCOREE.DLL, MSCORWKS.DLL, MSCORSVR.DLL
They are regular DLL's that also expose some COM interfaces.The public COM interfaces are polished in the mscoree.idl, while the public C style interfaces are in the mscorree.h file in the framework SDK. The mscorwks.dll are not published, that means they are private and should
therefore not be used from user code.
This object is implemented in either the mscorwks.dll or mscorsvr.dll, depending on factors such as a how many processors the system has or environment variable settings. Either of these DLLs are loaded by mscoree.dll, which acts as a shim to load either of the modules mscorwks or mscorsvr.
.NET Interoperability
Use P/Invoke for calling Windows API (or) Legacy Applications API functions from Managed Code.Using the P/Invoke service in the .NET Compact Framework includes three primary steps:
1.declaration
2.invocation
3.error handling.
Unload Assemblies using Code
We can unload assemblies by using AppDomain class. We can open make our own appDomain dynamically and ask a particular assembly to run in that appDomain. Also we can easily unload that appDomain.
AppDomain is a virtual location in memory where a process runs. Usually, each process runs in its own space and if first process making a call to second process, and if second process crashes, so first will also crash. So in .NET to solve this problem give us concept of AppDomains. The main process is created by the .NET CLR and then, each assembly runs in its own AppDomain. And many AppDomains can exist in a single process space. So, if one AppDomain crashes, only its space is released and the process remains as is.
This reduces the chances of a system crash. Also, if an AppDomain does crash, the CLR throws back an exception which can be handled in the caller appDomain.AppDomain Class: The AppDomain class is the programmatic interface to application domains. This class includes methods to create and unload domains, to create instances of types in domains, and to register for various notifications such as application domain unloading.
Links:
Programming with the .NET Framework - http://msdn.microsoft.com/en-us/library/aa720433(VS.71).aspx
A Guided Tour of Windows Presentation Foundation - http://msdn.microsoft.com/en-us/library/aa480221.aspx
Introduction to Microsoft .NET - http://www.w3schools.com/ngws/ngws_intro.asp
How to unload .NET Assemblies - http://www.codeproject.com/KB/dotnet/dotnet.aspx
.NET Interoperability - -http://msdn.microsoft.com/en-us/magazine/cc164123.aspx
Runtime Code Generation with JVM & CLR - http://www.itu.dk/~sestoft/rtcg/rtcg.pdf
JVM vs CLR memory allocation - http://benpryor.com/blog/2006/05/04/jvm-vs-clr-memory-allocation/
C# for C++ Developers - http://msdn.microsoft.com/en-us/library/yyaad03b.aspx
Sharp New Language: C# Offers the Power of C++ and Simplicity of Visual Basic -
http://msdn.microsoft.com/en-us/magazine/bb984953.aspx
http://msdn.microsoft.com/en-us/magazine/dd148640.aspx
http://msdn.microsoft.com/en-us/magazine/bb984953.aspx
http://www.codeproject.com/KB/interviews/jeffprosise17aug2000.aspx
Joshua Trupin of MSDN: What .NET means to developers -
http://www.codeproject.com/KB/interviews/interview_msdn_0103.aspx
The Future of Visual Basic: Web Forms, Web Services, and Language Enhancements Slated for Next Generation –
http://msdn.microsoft.com/en-us/magazine/bb985089.aspx
.NET StockTrader Sample Application(An End-to-End Sample Application Illustrating Windows Communication Foundation and .NET Enterprise Technologies) - http://msdn.microsoft.com/en-us/netframework/bb499684.aspx
.NET Getting Started -
http://msdn.microsoft.com/en-us/magazine/aa720108%28printer%29.aspx
http://www.pinvoke.net/
Miscellaneous URLs:
http://w3schools.com/aspnet/default.asp
http://dotnetspider.com/tutorials/
http://free-ebooks-for-u.blogspot.com/
