Saturday, April 10, 2010

Dual Boot OpenBSD/Ubuntu/Vista using GAG

GAG is a really nice boot manager. Very easy to install and very small in size.

My configuration is as follows
- I installed Vista first then installed OpenBSD 4.6 , then I installed GAG and everything works fine.

Second configuration
- Installed Ubuntu by replacing above Vista , and then later installed GAG but GAG does not work

The trick is when u install Ubuntu , Install grub on its own root partition such as /dev/sda2 and not on the disks MBR (/dev/sda)

Then when you install GAG things will work fine. The reason for this is GAG replaces whatever boot manager (grub) in the earlier case if grub is installed on the MBR. So to keep Ubuntu intact and make it work with GAG install grub on the linux partition.

/dev/sda1 - ubuntu (/ as ext4) -- This was previously Vista
/dev/sda2 - OpenBSD
/dev/sda5 - swap

GAG works with ext4

Wednesday, April 7, 2010

executing sql file though perl

The code is simple , no big deal . just documenting for possible reuse next time.
The blog just does not let me put the lessthan greaterthan symbol.

#!/usr/bin/perl

use Getopt::Std;

%options=();
getopts("s:",\%options);

&usage if (! defined( $options{s} ) );

my $sqlfile = $options{s};

my $login_file = "/home/reiki/.dev_login";
open (IP,"$login_file") || die "Cannot open file $login_file $!";
my $user_pass = ;
close IP;


open ORA, "| /oracle/reikidev/app/product/10.2.0/bin/sqlplus -s $user_pass" or die "Can't pipe to sqlplus: $!";
print ORA "set trimspool on echo on pagesize 500 linesize 20000 colsep ' '\n";

open (SF,"$sqlfile") || die "Cannot open file $sqlfile $!";
while (my $line = ) {
print ORA "$line";
}

print ORA "exit\n";
close ORA;
close SF;


sub usage {
print "usage: ./ut_reiki_exec_sql.pl -s sqlfile\n";
exit;
}

Tuesday, April 6, 2010

ksh 93

Ultimate Ksh book/reference by the creator of ksh himself.

Book title is
The New Kornshell - command and programming language.


print vs echo
echo is system dependent and provided for compatiblity with Bourne shell. print is used in the book instead of echo.

Saturday, April 3, 2010

global database name

select * from global_name;


show parameter db_domain


select name,value from v$parameter where name = 'db_domain';

byobu and screen

byobu is a nice wrapper to screen (gnu screen)

From the man pages

NAME
byobu - wrapper script for seeding a user's byobu configuration and launching screen

DESCRIPTION
byobu is a script that launches GNU screen in the byobu configuration. This enables the display of system information and status notifications within two lines
at the bottom of the screen session. It also enables multiple tabbed terminal sessions, accessible through simple keystrokes.

Calling sqlplus from shell,perl

#!/usr/bin/perl

open ORA, "| /u01/app/oracle/product/11.1.0/db_1/bin/sqlplus -s $user/$pass" or die "Can't pipe to sqlplus: $!";
print ORA "set trimspool on pagesize 500 linesize 200 colsep ' '\n";
print ORA "spool output.txt\n";
print ORA "select * from tab;\n";
print ORA "spool off\n";
print ORA "exit\n";
close ORA;


Calling from Korn shell

dblogin="`cat $HOME/.db_login`"

sqlplus -s $dblogin LESSTHANlessthanEOF | \
awk '{if(NR==1) printf("%s ", $1); \
if(NR==2) printf("%s ", $1); \
if(NR==3) printf("%s ", $1); \
if(NR==4) printf("%s ", $1); \
if(NR==5) printf("%s ", $1); \
if(NR==6) printf("%s ", $1); \
if(NR==7) printf("%s ", $1);} \
' | read t1_count \
t2_count \
t3_count \
t4_count \
t5_count \
t6_count \
t7_count

set head off pagesize 0 echo off verify off feedback off

select count(*) from t1
/
select count(*) from t2
/
select count(*) from t3
/
select count(*) from t4
/
select count(*) from t5
/
select count(*) from t6
/
select count(*) from t7
/
set head on echo on verify on feedback on
set lines 90
set pages 999
EOF

echo Table t1 has $t1_count rows
echo Table t2 has $t2_count rows

Pipes in Perl

#!/usr/bin/perl

open ORA, "| /u01/app/oracle/product/11.1.0/db_1/bin/sqlplus -s $user/$pass" or die "Can't pipe to sqlplus: $!";
print ORA "set trimspool on pagesize 500 linesize 200 colsep ' '\n";
print ORA "spool output.txt\n";
print ORA "select * from tab;\n";
print ORA "spool off\n";
print ORA "exit\n";
close ORA;

#-- list the processes running on your system
open(PS,"ps -e -o pid,stime,args |") || die "Failed: $!\n";
while ( )
{
print $_;
}

Followers

About Me

Torrance, CA, United States