<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\x3d11356004\x26blogName\x3dxception\x26publishMode\x3dPUBLISH_MODE_BLOGSPOT\x26navbarType\x3dBLUE\x26layoutType\x3dCLASSIC\x26searchRoot\x3dhttp://openrent.blogspot.com/search\x26blogLocale\x3den_US\x26v\x3d2\x26homepageUrl\x3dhttp://openrent.blogspot.com/\x26vt\x3d-2179510228592399674', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe" }); } }); </script>

Good point

In Unix, just about everything (including a network socket) is a file.

Extract email addresses from a file.

gawk 'BEGIN { RS = "[.@]*[^-0-9A-Za-z_.@]+[.@]*" } /@/' | uniq

Find the version of an Oracle database

Using SQLPlus, issue one of these two commands:

SELECT * FROM SYS.V_$VERSION;

select * from v$version where banner like ‘Oracle%’;

Run a command as user "x" in a shell script

Ever need to run a command as a specific user? Many Oracle commands require you to become the "oracle" user to make use of them.

To do this in a script, simply define your Oracle variables and use the "su" command. Here's some example code:

ORA_HOME=/d01/app/oracle/product/9.2.0
ORA_OWNER=oracle
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start listener_rmdyd1"
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start listener_hbstgu1"

FSCK an Oracle OCFS filesystem

With the filesystem unmounted:

$ fsck.ocfs /dev/sda1

Kaizen

Striving for perfection through ongoing improvement.

Remove OSS Java

The open source variant of Java is usually installed by default. If you don't want/need it, remove it with the following commands:

$ rpm -e java-1.4.2-gcj-compat-1.4.2.0-27jpp
$ rpm -e gcc-java

Record your actions

Just run the "script" command before you start typing anything. It will record all the actions you take at the command line in a readable file called 'typescript' in your current directory.

Clear a log file without deleting it

Need to clear out a log file to get rid of the "noise" in it? I do that often when tracking down a problem. However, deleting it usually means restarting the service that spawned it, which is not always possible (on a production server). The solution is to use redirection and the so-called "bit bucket" to get this done.

You clear the contents of a file (by sending it null data), but keep the file itself. Here's how:

Lets say we are not happy that the "lastlog" file has grown to 19 megabytes in size.

# ls -ltr lastlog
-r-------- 1 root root 19M Feb 6 12:34 lastlog

So we fill up the lastlog file with nothingness from /dev/null:
# cat /dev/null > lastlog

Ahhh, now lastlog is a good size!
# ls -ltr lastlog
-r-------- 1 root root 0 Feb 6 12:34 lastlog

List files by size

ls -lSr

Semaphone. Defined.

Semaphores can best be described as counters which are used to provide synchronization between processes or between threads within a process for shared resources like shared memories.

Test a JDBC connection to Oracle database

Many tools use JDBC to talk SQL to a database server. To verify your Oracle database's ability to respond to JDBC calls, compile the following small Java program into a file called JdbcCheckup.java.

// import the Oracle JDBC drivers
import oracle.jdbc.pool.OracleDataSource;

// You need to import the java.sql package to use JDBC
import java.sql.*;

// We import java.io to be able to read from the command line
import java.io.*;

class JdbcCheckup
{
public static void main (String args [])
throws SQLException, IOException
{

// Create an OracleDataSource and set URL
OracleDataSource ods = new OracleDataSource();
ods.setURL("jdbc:oracle:thin:system/apodevs@ausy01lo221:1525:apodevs");

System.out.print ("Connecting to the database...");
System.out.flush ();

// Connect to the database

System.out.println ("Connecting...");
Connection conn = ods.getConnection();

System.out.println ("connected.");

System.out.println ("Your JDBC configuration is correct.");

// Close the connection
conn.close();
}
}

Before this program will compile, you need three things:

1) Oracle credentials:
The name of the database instance, the port it is listening on, the system account password, and the Oracle server name. These variables need to be placed in the JDBC connection string URL in the Java code. The syntax of a JDBC URL for Oracle is:

jdbc:oracle:thin:system/@::

In practice, it might look like this:
jdbc:oracle:thin:system/apodevs@ausy01lo221:1525:apodevs

2) You will need to be running a JDK on the machine where you will be running this Java code. Any version will do.

3) Download the Oracle thin JDBC driver called "classes12.jar" from Oracle's website:
http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html

Once downloaded, place the JAR file in the jre|lib|ext directory of your installed JDK.

On Linux, place the JAR file in: /usr/java/jdk1.5.0_07/jre/lib/ext/
On Windows, place the JAR file in: C:\Program Files\Java\jdk1.6.0\jre\lib\ext

Now compile the .java file into a working class file: javac JdbcCheckup.java

Once compiled, you can run the program using the "java JdbcCheckup" command.