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
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 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:
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.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:
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:
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.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:\>
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:
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.sqlplus -s scott/tiger@oradb1.mycompany.com
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();
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 |
[machine with GNU tar]$ tar cfj dirname.tar.bz2 dirname |
[any UNIX machine]$ tar cf - dirname | bzip2 -c >dirname.tar.bz2 |
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 - |