Pages

Friday, July 25, 2014

Writting run time code in eclipse for debugging as in firebug console

While debugging an application/program in eclipse , go to the display screen in the side menu items with in the eclipse and type run time variables and execute the same like you would prefer to do in firebug, where you type commands and click on run.

 

Alternatively, to bring up the Display screen, you can go to

 

window->show view ->Display or Ctrl+Shift+D

 

I have simply heard about the same and have not tried it yet. So plz don’t blame me if it does not work for you.

 

Hope this works 0.0

 

Thursday, July 24, 2014

Customizing the UNIX User Environment - Part 1 - UNIX shell configuration files - Part 1

Customizing the UNIX User Environment

**********************************************************************************

UNIX shell configuration files

**********************************************************************************

Introducing shell configuration files

---------------------------------------

 

A shell is an interactive interface that you use to communicate with the UNIX kernel. It provides a way of executing commands and getting standard feedback in the UNIX environment.

 

Kernel is a software layer that enables interaction of the HLL with the hardware

 

The most commonly used UNIX shells unclude the

- Bourne shell - is the oriinal UNIX shell, developed by Stephen Bourne. It doesnot support some of the features of the more recent shells, such as command-line editing

- Korn shell - is similar to the Bourne Shell but incorprates features from the C shell - dev by David Korn

- Bash shell - is the GNU (operating system) implementation of the Bourne shell, and stands for Bourne Again Shell. It adds features such as command-line editing to the original Bourne shell.

- C shell - is a UNIX shell developed by Bill Joy. It is similar to the Bourne shell, but its command set has been adapted syntactically to match the C language.

 

Typically a shell runs in interactive mode, meaning that you can type commands into it and get results. It's also possible to run a shell non interactively. For example, while working in the Bash shell you might need to run a shell script that required the C shell. If properly configured, the script could invoke the C shell in a noninteractive mode long enough to complete the script's running.

 

When a shell starts up, it reads several different configuration files to learn how you want it to look and behave. Typically, a shell will begin by reading the /etc/profile file. This file contains global environment variables that the root user wants constant for all users, and only root can edit this file.

 

Once the shell has processed the /etc/profile file, it reads the .profile file located in the home direcotry of the user that started the shell. The initial period indicates that the file is hidden.

 

Because UNIX generally only reads the .profile file during login, specific shells have additional startup and configuration files. Both the Korn and Bash shells have an evironment variable called ENV that points to a script that is run whenever a new shell is started, not just at login.The name of the file that ENV poins to is arbitrary. However, by convention, on Bash it is called .bashrc, and on Korn .kshrc.

Customizing the UNIX User Environment - Part 1 - UNIX shell configuration files - Part 2

Customizing the UNIX User Environment

**********************************************************************************

UNIX shell configuration files

**********************************************************************************

 

Configuring user profiles

----------------------------------------

The file that most directly affects a user's experience of a shell is the .profile file located in a user'a home directory.

This file contains variables and commands that relate to how a user's shells will look and respond

 

Following is an example of a Bash shell .profile file.

 

bash-2.05a# cat .profile

#variables

SHELL=/bin/bash              #specifies path to the executable file for this shell

ENV=$HOME/.bashrc

PS1=$PWD

PATH=/usr/java/j2sdk_1_4_01/bin:$PATH

bash-2.05a#

 

Any line of text in a .profile file that begins with a hash (#) is a comment and the system ignores it.

Note: There are no mandatory .profile variables. Each variable shown here is an example, and is not strictly required to run a functional system.

 

ENV vairable specifies the path to the script that will be run for every subsequent instance of this shell-such as non interactive subshells launched by other scripts. It references the path value stored in the shell variable HOME - set elsewhere - by placing a dollar symbol ($) in front of the variable name.

 

The PS1 variable specifies the text that should be displayed as a prompt. In this case, it references the value stored in the PWS global variable, which is the path to the current working directory

 

The PATH variable specifies paths for the system to search for executables binaries. The PATH variable is normally set in the /etc/profile file. In this case, the value of the PATH variable is appended with additional information specifically for this user.

 

Followin gis a sample .bashrc file. which would normally be referenced by the EBV variable in a user's .profile file.

 

bash-2.05a# cat .bashrc

#Aliases

alias f=finger

alias fun=/usr/games

bash-2.05a#

 

Note : There are no mandatory .bashrc commands. Each command shown here is an example, and is not stricly required to run a functional system.

 

This .bashrc file contains alias commands that allow you to assign a shortcut name to a command or path, to minimize typing.

The first command assigns an alias of "f" to the finger command, which means you could now execute the finger command simply by typing f.

If the target of an alias consists of more than a single word, you should enclose it in single quotes.

 

The next alias command assigns an alias of "fun" to the path /usr/games. This means you could now navigate to that path by typing cd fun.

 

Alias commands can be executed from the shell prompt.

When the target of an alias is longer than a single word, you need to remember to enclose it in single quotes. In this case, the full statement reads as folloes:

alias list = 'ls -l|more'

 

Summary

--------------

A shell provides an interface for users to interact with the kernel. You configure shells using the /etc/profile and .profile files.

The .profile file contains variables and commands that configure a specific user's shell, but the file is usualy only referenced at login. Any commands that should be executed for every script should be placed in a separate file and referenced using the ENV variable.

Customizing the UNIX User Environment - Part 1 - Working with UNIX environment - Part 3

Customizing the UNIX User Environment

**********************************************************************************

Working with UNIX environment

**********************************************************************************

Global and local variables

-----------------------------

 

You use variables to customize how a shell looks, behaves, and responds to user input.

There are two kinds of variables: global or environment variables and local or shell variables

 

The root user sets global variables and stores them in the /etc/profiles file. Global variables affect all users' shells, providing standard parameters for any shell environment.

Programs running in the system have access to global variables, and use them to make behavior decisions.

 

Users can set theor own local variables, storing them in .profile files in their home directories.

Local variables affect a particular user's shell session only.

 

Some common global variables include

-EDITOR  - specifies default editor to use for general text edits. Default value is the vi text editor

-PATH  - specified one or more paths that the system will search for executable files when you enter a command at the shell prompt. The default setting is /usr/bin.

-PRINTER - specifies the default pronter. By default this is not set

-PS1 - specifies the prompt displayed in the shell. Default is $

-SHELL - specifies the path to the default shell program. on most systens this would be /bin/sh.

-TERM - specifies the default terminal used to access the system. The default value is vt100.

 

Some common local variables include

-HOME - specifies the path to the user's home directory

-LOGNAME - specifies the name that the user uses to log in with

-MAIL - specifies the path to the user's mailbox

 

When you set a global variable in a local context, the global variable gets overrided. Local variables are for customizing an individual user's experience of the system, so they override global variable values - for that user only.

 

You can view all of the currently set variables in your shell using the env command. Please type env in the console and hit enter to see the currently set variables

 

You can view the value of an individual variable using the echo command.

bash-2.05a$ echo $PATH

 

You need to prefix the variable name with a $ symbol in order to reference its contents rather than just typing it's name

 

In Bourne shell derivatives, you can set individual variables from the shell prompt by simply declaring them using the form variable=value.

The code shown here sets the value of the PS1 variable - the text that the shell displays as a prompt - to the current working directory, followed by a $.

 

The PS1 variable supports several switches to make it easier to configure, including

-\h - systems hostname

-\s - reference the name of the current shell

-\t - reference the current time in 24 hour format (HH:MM:SS)

-\u - reference your current username

-\w - reference the name of the current working directory

 

Once you've set the value of a variable you can force any subshells you launch to use the same value, using the export command, as shown here.

 

bash-2.05a$ PS1='\w$'

/home/ak$ export PS1

/home/ak$

 

Setting variables in the C shell is similar to Bourne variants, but requires the use of the setenv command.

The code shown here sets the value of the ld_library_path variable to /usr/lib.

 

easynomad2$ setenv ld_library_path variable to /usr/lib

easynomad2$

 

The C shell uses a different set of variables from the Bourne derivative shells. Because some of the variable names are the same, all C shell variables are expressed in lowercase.

 

Customizing the UNIX User Environment - Part 1 - Working with UNIX environment - Part 4

Customizing the UNIX User Environment

**********************************************************************************

Working with UNIX environment

**********************************************************************************

 

User environment commands

------------------------------------------------------------

UNIX comes with many standard command programs, stored in directories such as /bin, /usr/bin, and /sbin.

Shell programs have additional commands built into them. These commands are known as user environment - or built-in - commands.

 

One of the most useful built-in commands is the su command. Executed without arguments, it allows you to become the root user while logged into any other account, as shown here.

This is extremely convenient if you find yourself in need of admin privileges while logged in as another user, as it saves you having to logout and in again as root. If you use su, you will be required to supply the root password.

 

bash-2.05a$ su

Password:

su-2.05a#

 

When you've finished your admin task, you end your su session with the exit command, which returns you to your normal shell.

 

su-2.05a# exit

exit

bash-2.05a$

 

One of the functions of groups in UNIX is to allow members of groups to share files with each other, or to access resources that belong to the group.

If you need to move a fils, directory or other resource to a different group, you can do so using the built-in command chgrp.

 

Syntax: chgrp [-R] new _groupt object

It takes atleast two arguments: the destination group and the name of the object being moved. And you can specify the -R option if you're moving a directory and you want its subdirectories and all their contents to be moved as well.

 

You can get a lost of all users currently logged into the system using who command.

You can find out more about a currently logged in user using the finger command with their username as an argument

 

The finger command produces info abt a currently logged in user, including their fullname, the path to theor home directory, and which shell they're currently using.

 

Customizing the UNIX User Environment - Part 2 - Customizing X - Part 1

Customizing the UNIX User Environment

**********************************************************************************

Customizing X

**********************************************************************************

 

In UNIX systems, the X Window System - also called X - controls the interaction between the GUI display and the programs and applications that use it. The most popular and widespread of the X window System is XFree86

 

X architecture

------------------------

The X Window System uses a client-server architecture. The X server process runs on the computer that is displaying the GUI. This is usually a terminal or workstation.

 

The X client process runs on the computer that runs the application that suppies data to the GUI. This can be the same computer that displays the GUI, but it can also be a remote computer such as a network server.

 

Because X client applications can run on central network servers, you can implement networks where the terminal computers are very simple. X terminals need to have enough RAM and disk space to run the UNIX kernel and the X server procecss, but they dont need disk space for applications. They need a network card to communicate with servers, but they dont necessarily need a modem

 

Simple terminals that run only the kernel and X are called as X terminals. They function only as display terminals, with all application processing taking place on the server.

 

Although X hanfles the interaction between the GUI and the programs that display in it, X doesn't control the way windows look and behave.

The function is taken care of by window managers. These are programs that run on X servers. They rely on X for their interaction with the Kernel

 

The window manager determines the way window look on screen and the kind of controls - such as close and maximize buttons - that they have.

The window manager also controls the way users can move windows and alternate the focus between them.

 

There are many window managers for X, including Sawfish and Blackbox. Each window manager imarts its own look and feel to the GUI

 

The look and feel of a window manager depends on the set of GUI controls - or widgets - that it includes. Widgets are elements like buttons and drop-down lists. Each window manager has a different set of widgets

 

Because the UNIX GUI is made up of the X server process, a window manager, and usually a desktop environment, it requires much more processing and system resources than a command-line shell.

 

X is well suited to end-user computers like home PCs and office workstations. It shouldn't be used on busy servers like database and web servers because it uses system resources and slows down the server's vital operations.

 

A UNIX GUI can be comprised of an X server process, a window manager, and a desktop environment.

 

The X Window System also called X running on a computer are resource intensive, so you shouldn't use them on busy servers.

 

Customizing the UNIX User Environment - Part 2 - Customizing X - Part 2

Customizing the UNIX User Environment

**********************************************************************************

Customizing X

**********************************************************************************

 

Setting up an XFree86 server

-----------------------------------

XFree86 is the most widespread version of the X Window System. The latest version of XFree86 is version 4.x. Before you set up a computer to be an XFree 86 4.x server, you need to gather information about its display hardware. You need to find out about its

 

- monitor refresh rate - the horizontal scan rate and the vertical synchronization rate of the monitor

- display adapter chipset

- display adapter memory - determines the max resoulution and color depth that X can use.

 

To set up a computer as an XFree85 4.x server, you need to generate an initial X configuration file. To do this, you log in as the superuser and type the following at the shell prompt. Which inturn checks the computer's display hardware and generates a matching configuration file called XF86Config.new

 

bash-2.05a$ XFree86 - configure

bash-2.05a$ ls -l | grep 'XF86'

-rw-r--r-- 1 root wheel 2383 Oct 31 17:08 XF86Config.new

bash-2.05a$

 

You need to test whether the configuration file is set up correctly. To do this, you type the command statement shown here.

 

bash-2.05a$ XFree86 -xf86config XF86Config.new

 

XFree86 runs a test to determine whether X works with the configuration file. If it works, you should see a gray grid background with a black X-shaped cursor in the center.

 

To exit the test, you press Ctrl+Alt+Backspace.

 

Once you've generated and tested the XFree86 configuration file, you open the file using a text editor such as vi and tune it for the hardware and display configuration that you want.

The XFree86Config file consists of several sections, each of which deals with a specific area of X configuration.

The following sections specify basic XFree86 configuration settings

-Module - specifies optional modules that X can load when it start up. Eg font modules and double buffer extension (DBE) module

-Files - allows you to specify path to RGB color code db as well as paths to font directories

-Server flags - enable/disable various X server settings including detailed error messages

 

The following section of the XFree86Config file deal with the X server's input and output devices:

-Input devices - protocols & settings for i/p devices & specify props like keyboard layout, keystrike autorepeat speed, three-button mouse emulation etc..

-Monitor - horz scan rate and vert synchronization rate for monitor

-Graphics device - disp adapter and video memory

-Screen - color depth & resolution

-ServerLayout - configuring X for multiple monitors

 

You need to configure the refresh rate, color depth, and screen resolution before you can run X reliably

 

To specify the refresh rate of your monito, you open the XFb6Config file and go to the Monitor section.

You specify the horizontal refresh rate by assigning a value in KHz to the HorizSync parameter and you specify the vertical refresh rate by assigning a value in Hz to the VertRefresh parameter.

 

Note: You can find out your monito's refresh rates from the monitor's user manual or from the plaguw at the rear of the monitor.

 

To specify color depth and screen resolution, you go to the Screen section of the XF86Config file.

The Screen section contains multiple Display subsections, each of which applies to a particular color depth. You can set different screen resoluitons for each color depth.

 

To set the screen resolution for a particular color depth, you add a line to the relevant subsection and specify the resolution using the Modes parameter

 

You set the default color depth using the DefaultColorDepth parameter at the beginning of the Screen section.

When you start X, it displays at the default color depth and uses the screen resolution that you've specified in the Display subsection corresponding to that color depth.

 

Once you've finished editing the XF86Config file, you copy it to the /etc/X11 directory. X will then use this configuration fole each time you start X.

 

bash-2.05a$ cp XF86Config.new /etc/X11/XF86Config

 

Unless a computer has been configured to load X automatically at startup, you need to start X manually from the command prompt. You type the following command to do it

 

bash-2.05a$ startx

 

When X starts up, it also loads the window manager and desktop environment that are currently configured as defaults.

 

To shut down X, you choose Logout from the desktop's main menu or press cntrl+Alt+Backspace to kill X.

Customizing the UNIX User Environment - Part 2 - Customizing X - Part 3

Customizing the UNIX User Environment

**********************************************************************************

Customizing X

**********************************************************************************

 

Installing fonts

----------------------------

X can use a variety of fonts to display text in windows and on widgets. Before you can use these fonts, however, you need to install them and configure X so that it knows where to find the font files.

XFree86 4.x supports three types of fonts:

-Type 1 fonts - use an Adobe postsscript standard. They store the character glyphs and font metrics in two separate files

-TrueType fonts - use an Apple standard. They've also been widely adopted by Microsoft. They are highly scalable and store all their font info in a single file

-antialiased fonts - new feature of XFree86 4.x. They are rendered more smoothly than other types of fonts.

 

UNIX stores Type 1 fonts in several font directories that branch from /usr/ports/x11-fonts/.

These include the urwfonts directory and the free fonts directory.

 

To install donts from a font directory, you navigate to the directory and type

make install clean.

 

bash-2.05a$ cd urwfonts

bash-2.05a$ make install clean

 

when you install a set of fonts, UNIX creates font directories in /usr/X11R6/lib/X11/fonts/

 

To configure X so that it can access these fonts, you need to edit the Files section of the XF86Config file.

 

You add a FontPath row to the Files section, specifying the location of the font directory. In this case, you specify the path to the URW font directory.

 

XFree86 4.x supports TrueType fonts using an extension module called freetype. You need to enable this module so that X can access TrueType fonts.

 

To enable the freetype module, you edit the XF86Config file, adding the following row to the Modules section:

Load "freetype"

 

XFree86 4.02 and later versions support antialiasing for all scalable font types. However, many desktop toolkits don't support antialiasing. The Qr toolkit for the KDE desktop is one of those that do.

 

To enable antialising with Qt, you need to edit the /usr/X11R6/lib/X11/XftConfig file using a text editor such as vi. You add lines defining each of the font directories for which you want to enable antialiasing

 

Because antialiasing smooths out the edges of screen fonts, it makes small fonts more readable and large fonts more attractive. However, it causes eyestrain when applied to medium-size fonts.

 

To disable antialiasing for medium-size fonts, you add a section to the XftConfig file that matches a range of font sizes - in this case 10 to 14 points - and disables antialiasing for it.

 

On a large network, it may be better to set up a font server and configure X to look for fonts on the font server.

 

To configure X to use a font server, you need to edit the XF86Config file and add a FontPath line to the Files section that specifies the port number of the font server. If font server is on port 3 you would see something line

 

FontPath "unix:/3"

 

Note: this procedure sets up a system-wide font server. To add a user-specific font server, you need to edit the .xinitrc file in the user's home directory

 

 

 

Customizing the UNIX User Environment - Part 3 - UNIX X window managers and desktops - Part 1

Customizing the UNIX User Environment

**********************************************************************************

UNIX X window managers and desktops

**********************************************************************************

XDM

-----------

The X Display Manager (XDM) is a program that manages login sessions for the X Window System.

 

XDM prompts users for theor username and password. Then it authorizes them and opens a session on an X server for them.

When a user exits the X interface. XDM closes the session and prompts the next user for their username and password.

 

XDM is particularly useful in large network implementations that have more than one X dispay server. In such cases, XDM allows users to choose which server they want to connect to.

 

To start XDM, you run the XDM binary, which in this case is located in the /usr/X11R6/bin directory. You need to be logged in as root to do this.

 

You can configure a system so that XDM runs automatically when the system starts up. The procedure for doing this varies from one flavor of UNIX to another.

 

If you're using a system with virtual terminals - such as FreeBSD - you can add a line to the /etc/ttys file that automatically runs XDM in one of the virtual terminals. In this example, XDM uses the ninth virtual terminal.

 

Once you've started XDM, it display a graphical login window whenever a user needs to login.

You can customize the appearance of this window. This example shows a common default.

 

You can configure XDM by editiong the following files, all of which are located in /usr/X11R6/lib/X11/xdm:

- xdm-config - file contains flobal default settings that apply to all of the displays to which users can connect

- xdm-errors - file contains a record of error messages generated by the X sessions that XDM runs. It's useful for troubleshooting

- xdm-pid - file allows you to specify the process ID of the XDM process.

- Xaccess - file contains a set of rules for controlling access to XDM. You can use it to determine how remote X client connections are authorized.

- Xresources - file contains default settings for the appearance of the login screen, and specifies the default display server.

- Xservers - file lists all the remote display servers to which users of XDM can connect. They can choose any of these servers when they log in.

- Xsession - file is the default session script that runs when users log in and start a session.

 

Note : The directory in which these files are located may differ depending on the UNIX implementation you're using.

 

In addition to the XDM configuration files, the /usr/X11R6/lib/X11/xdm directory contains a set of display setup scripts.

These scripts are named Xsetup_0, Xsetup_1, and soon. You can use them to specify background processes that run automatically when XDM starts an X session on a particular display.

Customizing the UNIX User Environment - Part 3 - UNIX X window managers and desktops - Part 2

Customizing the UNIX User Environment

**********************************************************************************

UNIX X window managers and desktops

**********************************************************************************

Integrated desktop environments

-----------------------------------------------------------------------------------

Integrated desktop environments provide an attractive and user-friendly interface to UNIX systems. It is a preconfigured session of a window manager.

 

Integrated desktop environemnts commonly contain

- default settings for window appearance and behavior

- a set of defautl widgets

- a set of desktop backgrounds

- default desktop icons such as a recycle bin

- a panel for managing tasks and workspaces

 

There are three common integrated desktop envionments for UNIX

- Common Desktop Environment (CDE)

- Gnome

- Kool Desktop Environment (KDE)

 

All of the above mentioned evnironment have at the minimum, A trash icon, easy access drip-down menus and workspace buttons in common

 

KDE is bundled with its own window manager, while Gnome i most commonly used with Sawfish. Desktop environments and window managers are distinct GUI components - you are not obliged to have a window manager but, when you do, it sits on top of your desktop.

 

Summary

---------

The X Display Manager (XDM) is a program that manages login sessions for the X Window System. XDM prompts users for their username and password. Then it authorizes them and opens a session on an X server for them. When a user exits the X interface, XDM closes the session and prompts the next user for their username and password.

 

Window managers are programs that run on an X server and determine the appearance and behavior of windows in the GUI environment. For example, window managers determine window colors and borders, button size and style, and focus policy.

 

Integrated desktop environemnts are preconfigured sessions of a window manager, providing default widgets, icons, and backgrounds. Most of them include a panel that allows you to manage tasks and workspaces. The three most popular desktop environments are the Common Desktop Environment(CDE), Gnome, and the Kool Desktop Environment (KDE).