Thursday, June 30, 2005

Bash Scripting

1.
To debug
bash -x script.sh

2. Variable assignments ( no spaces in between )
x=0;
y="kalyan";

3. String comparisons, use

=, <= etc
For numeric comparison
-lt, -gt, -eq

Quote Strings in comparisons. Will add some examples later

New-logon option in SQLPLUS

New -LOGON option to SQL*Plus

by Jeff Hunter, Sr. Database Administrator



The -LOGON option was added to SQL*Plus in Oracle9i to help alleviate attacks and break-ins by hackers. By default, when a users attempts to login to the database using SQL*Plus with an invalid username/password combination, the database displays the error message:

C:\> sqlplus scott/badpassword

SQL*Plus: Release 9.2.0.3.0 - Production on Fri Jul 18 17:11:08 2003

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

ERROR:
ORA-01017: invalid username/password; logon denied


Enter user-name:
The attempt to login to the database errors out, but the username prompt remains. After three attempts, the return goes back to the operating system prompt. However, until then, the username prompt remains. Most security conscious organizations consider this bad policy, especially when running batch programs. In cases like this, it is a strict requirement that the application return to an OS prompt as soon as the first error is reported.

This is where the new LOGON option introduced in Oracle9i comes into play. The LOGON option is used to stop attempting connecting to the database after the first failure. Using the above example, we could login to SQL*Plus using the following syntax:

C:\> sqlplus -s -LOGON scott/badpassword
ERROR:
ORA-01017: invalid username/password; logon denied


SP2-0751: Unable to connect to Oracle. Exiting SQL*Plus

C:\>
In the above example, you can see that when the connection fails, regardless of the reason, the control returns to the operating system immediately after reporting the error - the username prompt is not displayed.

The LOGON option can also provide usefulness in writing a script to automate the checking of a database's availability. A common approach used by DBAs is to have a shell script with something similar to the following:

sqlplus -s scott/tiger@oradb1.mycompany.com 
If the connection does not succeed for some reason, because either the listener is down or the database is down, or because the userid and password combination is wrong, the script does not return to the operating system prompt. In an automated script, it will hang, making the script useless. Using the -LOGON option here can make the script useful in these automated situations.

Wednesday, June 29, 2005

Printing Solaris Diagnostic Information

System Administration Commands prtdiag(1M)

NAME
prtdiag - display system diagnostic information

SYNOPSIS
/usr/platform/platform-name/sbin/prtdiag [-v] [-l]

DESCRIPTION
prtdiag displays system configuration and diagnostic infor-
mation on sun4u systems.

The diagnostic information lists any failed field replace-
able units (FRUs) in the system.

The interface, output, and location in the directory hierar-
chy for prtdiag are uncommitted and subject to change in
future releases.

platform-name is the name of the platform implementation and
can be found using the -i option of uname(1).

Note:

prtdiag does not display diagnostic information and
environmental status when executed on the Sun Enter-
prise 10000 server. See the
/var/opt/SUNWssp/adm/${SUNW_HOSTNAME}/messages file on
the system service processor (SSP) to obtain such
information for this server.

OPTIONS
The following options are supported:

-l Log output. If failures or errors exist in the system,
output this information to syslogd(1M) only.

-v Verbose mode. Displays the time of the most recent AC
Power failure, and the most recent hardware fatal
error information, and (if applicable) environmental
status. The hardware fatal error information is useful
to repair and manufacturing for detailed diagnostics
of FRUs.

EXIT STATUS
The following exit values are returned:

0 No failures or errors are detected in the system.

1 Failures or errors are detected in the system.

2 An internal prtdiag error occurred, for example, out
of memory.

SunOS 5.9 Last change: 19 Dec 2001 1

System Administration Commands prtdiag(1M)

ATTRIBUTES
See attributes(5) for descriptions of the following attri-
butes:

____________________________________________________________
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
|_____________________________|_____________________________|
| Availability | SUNWkvm |
|_____________________________|_____________________________|

SEE ALSO
uname(1), modinfo(1M), prtconf(1M), psrinfo(1M), sysdef(1M),
syslogd(1M), attributes(5), openprom(7D)

Installing mod_perl with apache

1. Installing mod_perl
command to fire
perl Makefile.PL APACHE_SRC=../apache_1.3.33/src APACHE_PREFIX=/local/apache-1.3 DO_HTTPD=1 USE_APACI=1 EVERYTHING=1

-Kalyan

Sunday, June 26, 2005

StringTokenizer in C#

There is no equivalent to StringTokenizer of Java in C#

what to use then?

string line = "practice of programming";
string values[] = line.Split(' ');

values will have the results .. delimited by space

-Kalyan

Saturday, June 25, 2005

A bit of preliminary C#

Things to be done,

1. Read a text file.
2. Insert only the first entry for the user in a Database table.
3. Run analysis services for clustering results

Text files are read and written through the StreamReader and StreamWriter classes. There are various ways to create instances of these classes—for example,

string file_name = @"C:\fictions\gnome.txt";

StreamReader freader = File.OpenText( file_name );
StreamWriter fwriter =
File.CreateText( @"C:\fictions\gnome.diag" );

 string text_line;
while (( text_line = freader.ReadLine() ) != null )
{
// Instead of this I want to insert it in a database table
// write to output file
fwriter.WriteLine( text_line );
}

// must explicitly close the readers
freader.Close();
fwriter.Close();


How do i do SQL Server programming usin C# ( did it before but forgot .. :) )
From c-sharpcorner.com
using System;
using System.Data;
using System.Data.SqlClient;

namespace SimpleSql1
{
class Insert
{
[STAThread]
static void Main(string[] args)
{
SqlConnection conn = new SqlConnection("Data Source=Computername;"+ // TODO: change comp name
"Initial Catalog=simplesql;"+
"User ID=sa;"+
"Password=pass;");

string strText = Console.ReadLine();

try
{
SqlCommand cmd = new SqlCommand();
cmd.CommandTimeout = 60;
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT Count(*) FROM simplesql";// Couldn't do it without sorry

conn.Open();
if (conn.State == ConnectionState.Open)
{
object objCount = cmd.ExecuteScalar();
int iCount = (int) objCount;
Console.WriteLine("Count was succesfull");

cmd.CommandText = "INSERT INTO simplesql (simple_id, simple_text) VALUES ("+
iCount +",'"+ strText +"')";
cmd.ExecuteScalar();
Console.WriteLine("Succesfully inserted the string");
}
}
catch (Exception exp)
{
Console.Write(exp.Message);
}
finally
{
conn.Close();
}

Console.WriteLine("\n\n Press any key to quite");
Console.Read();
}
}
}

Friday, June 24, 2005

Installing plugins for firefox and Acrobat Reader 7

1. Installing firefox involves dowloading the build and executing it :) , does it not get simpler than that
Well ofcourse you can get your hands dirty by building it from source.

2. How do I install plugins:

A smart trick to do that : about:plugins (shows which all plugins are installed for firefox)

And the firefox install has a plugins directory,

1. For installing macromedia, copy the flashplayer.xpt and libflashplayer.so into the plugins directory of firefox.

2. For java we can make a symbolic link.
ln -s libjavaplugin_oji.so


Installing Acrobat Reader 7 on solaris, it conflicts with the LD_LIBRARY_PATH .
A GOOD PHILOPSHY of running a program is provide a script and let the user modify the script , in acroread , is a script and in the script i unset the LD_LIBRARY_PATH ( so that is pretty fascinating)

-Kalyan

Thursday, June 23, 2005

Unix File Compression Utilities

File Utilities

Archiving and Compressing Files

On UNIX and Linux systems, gzip is probably the most common compression program. The newer but less common bzip2 gives significantly better compression. To compress a single file,

[any UNIX machine]$ bzip2 filename
[any UNIX machine]$ gzip filename
To archive and compress a directory on a machine with a newer version of GNU tar
[machine with GNU tar]$ tar cfj dirname.tar.bz2 dirname
[machine with GNU tar]$ tar cfz dirname.tar.gz dirname
The “j” option tells tar to compress with the more powerful bzip2 and the “z” option tells it to compress with the more commonplace gzip. If GNU tar is not available,
[any UNIX machine]$ tar cf - dirname | bzip2 -c >dirname.tar.bz2
[any UNIX machine]$ tar cf - dirname | gzip -c >dirname.tar.gz

You can give several file and directory names to the tar command. It is a good practice, though, to keep everything in one toplevel subdirectory, to avoid “polluting” the current directory when later extracting the archieve. (Imagine that you extract an archieve with hundreds of files into your home directory. There is a real chance of overwriting existing files, and it may take some time to move files to a more proper place.)

To uncompress the “.tar.gz” and “.tar.bz2” files,

[any UNIX machine]$ bunzip2 -c dirname.tar.bz2 | tar xf -
[any UNIX machine]$ gunzip -c dirname.tar.gz | tar xf -

[machine with GNU tar]$ tar xfj dirname.tar.bz2
[machine with GNU tar]$ tar xfz dirname.tar.gz

Wednesday, June 22, 2005

Finding Open Oracle Connection

to find oracle open connection obviously you need to be a administrator privileges and the query to fire is

select * from v$session where username= ?,

v$session is the table to watch out for?

-Kalyan

How to enter passwords in shell?

echo "Enter password:"
stty -echo
read password
stty echo
echo

Need to find as to which oracle seesions are active, need to kill session which are of particular user.
SQLPLUS + SHELL scritps

Tuesday, June 21, 2005

What is the shell?

The environment variable $SHELL specifies which shell we're running

http://www.softlab.ntua.gr/facilities/documentation/unix/shelldiff.html#6

Friday, June 17, 2005

Things to do list for the SysAdmin thing and misc

1. Get the O'Reilly SystemAdmin Book.:
2. RT issues ( Move apache to /local and my sql in future too).
3. Installing a weblog.
4. Oracle user creation scripts with sharing tablespace feature which makes the life of admin simple.
5. Sed and Awk and their uses.

Other Things to be taken care of:
1. Estimate for text clustering using MS SQL Server 2000 Analysis Services.
2. Proposal with co-training and hypergraph clustering, the algorithm, timeline and conclusion.
3, N-order markov chains
4. Sensor net paper
5. Adding the dm3dcube thing to CVS
6. Ading preproposal to CVS

More Misc:
1. PIE
2. WMMF
3. PP
4. MPP
5. NIS and NFS

Installing a WebLog

Now I have this task of installing a weblogger for internal use which should not expose the data to the outside world. That kinda defeats the purpose of the blog but requirement so need to go ahead and install it.

I am comparing various webloggers and evaulating them :
1. Roller Weblogger ( This is written in java and should be platform independent because of the java portability) Installation is supposed to have tomcat in it which kinda i think is supposed to take more time.

2. So i need a more simple life and looking at other options of installing the software. Currently i am interested in looking into the weblogger which only involves using the apache configuration.

-kalyan

Thursday, June 16, 2005

UNIX Revisited

1. After exiting from a single user mode, init executes the system startup scripts.
2. Scripts are placed in /etc/init.d and they are linked to /etc/rcX.d
3.
Soft links are created from init.d to rcX.d

Wednesday, June 15, 2005

Concept Hierarchy

http://profusion.bu.edu/techlab/Docs/Tan__Concept_Hierarchy_Memory_Model.pdf

Eclipse plugin install:
Plugin install for eclipse is get the zip and install it in the directory of plugins and directory of features

Eclipse
1. plugins
2. features

Extract the files into these directories.

-Kalyan

Request Tracker Biggest Issue

The request tracker ticket creation is a big pain, I think i was able to solve the ticket creation issue but it has cropped up again ... since i forgot what i did to resolve it ( some permission problem) need to look and document it..

Things which i have tried and which does not work
1. User and group setting in web apache server ( www and other , kosh and other does not solve the purpose)
2. Putting the rt-mailgate entried in /etc/mail/aliases that too does not serve the purpose
3.