Tuesday, December 11, 2012

Rman / ORACLE


$rman target / nocatalog

Recovery Manager: Release 10.2.0.5.0 - Production on Tue Dec 11 16:05:05 2012

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

connected to target database: SFT (DBID=2981456125)
using target database control file instead of recovery catalog

RMAN> delete noprompt archivelog until time 'sysdate-2/24';

Thursday, November 29, 2012

Wednesday, November 28, 2012

Oracle [ db_recovery_file_dest_size ]


SQL> SELECT * FROM V$RECOVERY_FILE_DEST;

NAME SPACE_LIMIT SPACE_USED SPACE_RECLAIMABLE NUMBER_OF_FILES
------------------------------------------------------------ ----------- ---------- ----------------- ---------------
/u01/app/oracle/FLASH_RECOVERY_AREA 3.2212E+10          0                 0               0


SQL> show parameter db_recovery_file_dest_size

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest_size           big integer 30G

SQL> alter system set db_recovery_file_dest_size=100G;

System altered.


SQL> show parameter db_recovery_file_dest_size

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest_size           big integer 100G



Oracle Tablespace [ Check +ASM | Add Tablespace]


Check +ASM
SQL> select name, total_mb, free_mb from v$asm_diskgroup;

Check Disk
SQL> show parameter create

Add Tablespace
SQL> alter tablespace users add datafile size 1000m autoextend on next 500m maxsize 8000m;

Check Tablespace autoextend
SQL> desc dba_data_files;

SQL> select Tablespace_name, file_name, bytes/1024/1024 mbytes, AUTOEXTENSIBLE, MAXBYTES/1024/1024 maxbytes, INCREMENT_BY nextmb
from dba_data_files

Monday, November 12, 2012

WMI Work [ Windows ]


Info Disk

C:\Users\Administrador>wmic LOGICALDISK Get DeviceID,Caption,description,size,freespace
Caption  Description       DeviceID  FreeSpace   Size
C:       Local Fixed Disk  C:        6752161792  21472735232
D:       CD-ROM Disc       D:        0           40814592

Info Disk

C:\Users\Administrador>wmic logicaldisk get Caption, Description, Filesystem
Caption  Description       FileSystem
C:       Local Fixed Disk  NTFS
D:       CD-ROM Disc       CDFS

Info Task Memory

C:\Users\Administrador\Documents\IdaDB>wmic path win32_perfformatteddata_perfproc_process get IOReadOperationsPersec, IOWriteBytesPersec, Name, PercentProcessorTime, PercentUserTime, VirtualBytes, WorkingSet, WorkingSet, WorkingSetPeak, WorkingSetPrivate

Info Task Memory

C:\Users\Administrador\Documents\IdaDB>wmic path win32_perfformatteddata_perfproc_process

Friday, November 9, 2012

Thursday, November 8, 2012

Windows [ Add Variables PATH ] Oracle


C:\Users\Administrador>sqlplus /nolog
'sqlplus' não é reconhecido como um comando interno
ou externo, um programa operável ou um arquivo em lotes.

C:\Users\Administrador>echo %PATH%
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\strawberry\c\bin;C:\s
trawberry\perl\site\bin;C:\strawberry\perl\bin;C:\Windows\System32\WindowsPowerS
hell\v1.0\

C:\Users\Administrador>set PATH=%PATH%;C:\oraclexe\app\oracle\product\11.2.0\ser
ver\bin

C:\Users\Administrador>echo %PATH%
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\strawberry\c\bin;C:\s
trawberry\perl\site\bin;C:\strawberry\perl\bin;C:\Windows\System32\WindowsPowerS
hell\v1.0\;C:\oraclexe\app\oracle\product\11.2.0\server\bin

C:\Users\Administrador>sqlplus /nolog

SQL*Plus: Release 11.2.0.2.0 Production on Qua Nov 7 01:27:48 2012

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

SQL> connect sys as sysdba
Informe a senha:
Conectado.
SQL>
SQL>

Thursday, November 1, 2012

Oracle [ Instance idle ]


1 - step

SQL> connect sys as sysdba
Enter password:
Connected to an idle instance.
SQL>
SQL>
SQL> startup
ORACLE instance started.
SQL> quit


2 - step

SQL> connect sys as sysdba
Enter password:
Connected.
SQL>
SQL> alter system switch logfile;

System altered.

SQL> alter system checkpoint;

System altered.

SQL> quit


Oracle / Linux [ BASH Notify DB ]

[root@localhost notify]# cat notify.sh
sqlplus /nolog << EOF
connect system/12345
@names_sid.sql
quit
EOF

[root@localhost notify]# cat names_sid.sql
spool /home/siltech/name.log
select name from v$database
/
spool off

[root@localhost notify]# cat /home/siltech/name.log

NAME                                                                           
---------                                                                      
XE

Thursday, October 25, 2012

Wednesday, October 17, 2012

Monday, October 15, 2012

Oracle - [ dbms_scheduler ]

SQL> select owner,job_name,enabled from all_scheduler_jobs;

OWNER                          JOB_NAME                       ENABL
------------------------------ ------------------------------ -----
SYS                            XMLDB_NFS_CLEANUP_JOB          FALSE
SYS                            SM$CLEAN_AUTO_SPLIT_MERGE      TRUE
SYS                            RSE$CLEAN_RECOVERABLE_SCRIPT   TRUE
SYS                            FGR$AUTOPURGE_JOB              FALSE
SYS                            BSLN_MAINTAIN_STATS_JOB        TRUE
SYS                            DRA_REEVALUATE_OPEN_FAILURES   TRUE
SYS                            HM_CREATE_OFFLINE_DICTIONARY   FALSE
SYS                            ORA$AUTOTASK_CLEAN             TRUE
SYS                            FILE_WATCHER                   FALSE
SYS                            PURGE_LOG                      TRUE
APEX_040000                    ORACLE_APEX_DAILY_MAINTENANCE  TRUE

OWNER                          JOB_NAME                       ENABL
------------------------------ ------------------------------ -----
APEX_040000                    ORACLE_APEX_WS_NOTIFICATIONS   TRUE
APEX_040000                    ORACLE_APEX_MAIL_QUEUE         TRUE
APEX_040000                    ORACLE_APEX_PURGE_SESSIONS     TRUE

14 rows selected.


SQL> begin
  2  dbms_scheduler.drop_job(job_name=>'SYS.PURGE_LOG');
  3  end;
  4  /

PL/SQL procedure successfully completed.


SQL> begin
  2  dbms_scheduler.enable('FILE_WATCHER');
  3  end;
  4  /

PL/SQL procedure successfully completed.


SQL> begin
  2  dbms_scheduler.disable('FILE_WATCHER');
  3  end;
  4  /

PL/SQL procedure successfully completed.

Monday, October 1, 2012

Makefile [ Automation modules for installation ] PERL

#Commands
CD_IN='cd'
CD_OUT='cd ..'
TAR='tar -xvf'
PERL_MAKEFILE='perl Makefile.PL'
MAKE='make'
MAKE_INSTALL='make install'
CHMOD='chmod +x Makefile'

#Module
M1=List-MoreUtils-0.33
M2=ExtUtils-MakeMaker-6.62
M3=Perl-OSType-0.005
M4=Module-Metadata-1.000011
M5=PathTools-3.33
M6=Locale-Maketext-Simple-0.21
M7=Module-CoreList-2.73
M8=Module-Load-0.22
M9=Params-Check-0.36
M10=Module-Load-Conditional-0.54
M11=IPC-Cmd-0.78
M12=ExtUtils-CBuilder-0.280205
M13=ExtUtils-ParseXS-3.15
M14=Test-Simple-0.98
M15=Perl-OSType-1.002
M16=Test-Harness-3.25
M17=Compress-Raw-Bzip2-2.055
M18=Compress-Raw-Zlib-2.056
M19=IO-Compress-2.055
M20=IO-Zlib-1.10M25=ExtUtils-Install-1.54

M21=Package-Constants-0.02
M22=Algorithm-Diff-1.1902
M23=Text-Diff-1.41

M24=Archive-Tar-1.90
M25=ExtUtils-Install-1.54
M26=Module-Build-0.4003
M27=Config-IniFiles-2.77
M28=DBD-Oracle-1.50
M29=DBI-1.622

#Uncompress
FILE_GZ=`ls *.gz`
for i in ${FILE_GZ} ; do \
        ${TAR} ${i}
done;

#Execute Install
for i in ${M1} ${M2} ${M3} ${M4} ${M5} ${M6} ${M7} ${M8} ${M9} ${M10} ${M11} ${M12} ${M13} ${M14} ${M15} ${M16} ${M17} ${M18} ${M19} ${M20} ${M21} ${M22} ${M23} ${M24} ${M25} ${M26} ${M27} ${M28} ${M29} ; do \
        ${CD_IN} ${i}
        ${PERL_MAKEFILE}
        ${CHMOD}
        ${MAKE}
        ${MAKE_INSTALL}
        ${CD_OUT}
done;

#Delete Dir
DIR=`ls -d */`
for i in ${DIR}; do \
        rm -rf ${i}
done;

Friday, September 28, 2012

PERLCC MODULE


1.     List-MoreUtils-0.33.tar.gz
2.     ExtUtils-MakeMaker-6.62.tar.gz
3.     Perl-OSType-0.005.tar.gz
4.     Module-Metadata-1.000011.tar.gz
5.     PathTools-3.33.tar.gz
6.     Locale-Maketext-Simple-0.21.tar.gz
7.     Module-CoreList-2.73.tar.gz
8.     Module-Load-0.22.tar.gz
9.     Params-Check-0.36.tar.gz
10.  Module-Load-Conditional-0.54.tar.gz
11.  IPC-Cmd-0.78.tar.gz
12.  ExtUtils-CBuilder-0.280205.tar.gz
13.  ExtUtils-ParseXS-3.15.tar.gz
14.  Test-Simple-0.98.tar.gz
15.  Perl-OSType-1.002.tar.gz
16.  Test-Harness-3.25.tar.gz
17.  Compress-Raw-Bzip2-2.055.tar.gz
18.  Compress-Raw-Zlib-2.056.tar.gz
19.  IO-Compress-2.055.tar.gz
20.  IO-Zlib-1.10.tar.gz
21.  Package-Constants-0.02.tar.gz
22.  Algorithm-Diff-1.1902.tar.gz
23.  Text-Diff-1.41.tar.gz
24.  Archive-Tar-1.90.tar.gz
25.  ExtUtils-Install-1.54.tar.gz
26.  Module-Build-0.4003.tar.gz
27.  Config-IniFiles-2.77.tar.gz
28.  DBD-Oracle-1.50.tar.gz
29.  DBI-1.622.tar.gz

Tuesday, September 25, 2012

Perl [ Generate executables from Perl / Binary file]

File Hello.pl
---------------------------------------------
#!/usr/bin/perl
use strict;
use warnings;

print "Hei man !!! \n";
---------------------------------------------

[root@localhost Desktop]# perlcc -o Hello Hello.pl
[root@localhost Desktop]# chmod +x Hello
[root@localhost Desktop]# ./Hello
Hei man !!!
[root@localhost Desktop]# less Hello
"Hello" may be a binary file.  See it anyway?

Wednesday, September 19, 2012

Install [ Oracle 11g XE on Red Hat ]

#rpm -i oracle-xe-11.2.0-1.0.x86_64.rpm
Executing post-install steps...
You must run '/etc/init.d/oracle-xe configure' as the root user to configure the database.

[root@localhost Disk1]# /etc/init.d/oracle-xe configure

Oracle Database 11g Express Edition Configuration
-------------------------------------------------
This will configure on-boot properties of Oracle Database 11g Express
Edition.  The following questions will determine whether the database should
be starting upon system boot, the ports it will use, and the passwords that
will be used for database accounts.  Press <Enter> to accept the defaults.
Ctrl-C will abort.

Specify the HTTP port that will be used for Oracle Application Express [8080]:

Specify a port that will be used for the database listener [1521]:

Specify a password to be used for database accounts.  Note that the same
password will be used for SYS and SYSTEM.  Oracle recommends the use of
different passwords for each database account.  This can be done after
initial configuration:
Confirm the password:

Do you want Oracle Database 11g Express Edition to be started on boot (y/n) [y]:y

Starting Oracle Net Listener...Done
Configuring database...Done
Starting Oracle Database 11g Express Edition instance...Done
Installation completed successfully.


----------------------------------------------------------------------------------------------------------
 
Edit .bashrc

[root@localhost ~]# vim .bashrc
# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'


# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

#ORACLE CONFIG
ORACLE_HOSTNAME=localhost.localdomain; export ORACLE_HOSTNAME
ORACLE_UNQNAME=DB11G; export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/xe; export ORACLE_HOME
ORACLE_SID=XE; export ORACLE_SID
NLS_LANG=`$ORACLE_HOME/bin/nls_lang.sh`; export NLS_LANG
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH

if [ $USER = "oracle" ]; then
  if [ $SHELL = "/bin/ksh" ]; then
    ulimit -p 16384
    ulimit -n 65536
  else
    ulimit -u 16384 -n 65536
  fi
fi


----------------------------------------------------------------------------------------------------------
[root@localhost ~]# sqlplus

SQL*Plus: Release 11.2.0.2.0 Production on Wed Sep 19 10:52:11 2012

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Enter user-name: system
Enter password:

Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production

SQL>

Tuesday, September 18, 2012

Friday, September 14, 2012

Google [ Chart Tools ]


<html>
  <head>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
      google.load("visualization", "1", {packages:["corechart"]});
      google.setOnLoadCallback(drawChart);
      function drawChart() {
        var data = google.visualization.arrayToDataTable([

          ['ASW Africano/EUA',   1],
          ['CEU Utah/Europeia',    1],
          ['CHB Pequim/China',    1],
          ['CHD Chinesa/Colorado',    1],
          ['GIH Guzerate, Texas',    1],
 ['JPT Toquio/Japao',    1],
 ['LWK Luhya/Quenia',    1],
 ['MXL Mexicana/Los Angeles,California',    1],
 ['MKK Maasai/Kinyawa, Quenia',    1],
 ['TSI Toscani/Italia',    1],
          ['YRI Ioruba/Nigeria',    1]
        ]);

        var options = {
       
        };

        var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
        chart.draw(data, options);
      }
    </script>
  </head>
  <body>
    <div id="chart_div" style="width: 900px; height: 500px;"></div>
  </body>
</html>
---------------------------------------------------------------------------------------------------------
fonte : https://developers.google.com/chart/

Wednesday, September 12, 2012

Perl - [ Create | Insert - DB Oracle ]


use strict;
use warnings;
use DBD::Oracle qw(:ora_types);
use DBI;

use constant SqlOracle => 'C:\oraclexe\app\oracle\product\10.2.0\server\BIN\sqlplus.exe\\';
use constant User => 'system';
use constant Pass => '12345';
use constant DB => 'XE';


print "Test Show Valeu : $0\n";


my $dbh = DBI->connect("dbi:Oracle:".DB,User,Pass) or die $!;

my $CreateTable = "CREATE TABLE EMPREGADO (codigo number(6) primary key, nome varchar2(25) not null, salario number(11,2))";

my $sth = $dbh->prepare($CreateTable);

$sth->execute();

$sth = $dbh->prepare( q{INSERT INTO EMPREGADO (codigo,nome,salario) VALUES(?,?,?)}) or die $dbh->errstr;

open(IN,"pessoas.txt") or die $!;

while(<IN>){
chomp;
my($codigo,$nome,$salario) = split (/\t/,$_);
$sth->execute($codigo,$nome,$salario) or die $dbh->errstr;

}
close(IN);

$dbh->disconnect;

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


SQL> desc empregado;
 Nome                                      Nulo?    Tipo
 ----------------------------------------- -------- ----------------------------

 CODIGO                                    NOT NULL NUMBER(6)
 NOME                                      NOT NULL VARCHAR2(25)
 SALARIO                                            NUMBER(11,2)

SQL> select * from empregado;

    CODIGO NOME                         SALARIO
---------- ------------------------- ----------
         1 joao                              10
         2 maria                             80
         3 jose                              60

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

pessoas.txt

1 joao 10
2 maria 80
3 jose 60


Perl - [ Perl DBI Oracle connect from Windows ]

use strict;
use warnings;
use DBD::Oracle qw(:ora_types);
use DBI;

use constant SqlOracle => 'C:\oraclexe\app\oracle\product\10.2.0\server\BIN\sqlplus.exe\\';
use constant User => 'system';
use constant Pass => '12345';
use constant DB => 'XE';

print "Create connection Oracle Database 10g Express Edition  ... 1\n";
my $dbh = DBI->connect("dbi:Oracle:".DB,User,Pass) or die $!;

print "Disconnect Oracle Database 10g Express Edition ...\n";
$dbh->disconnect;

print "Create connection Oracle Database 10g Express Edition  ... 2\n";
$dbh = DBI->connect("dbi:Oracle:".DB,User."/".Pass) or die $!;

print "Disconnect Oracle Database 10g Express Edition ...\n";
$dbh->disconnect;
print "Create connection Oracle Database 10g Express Edition  ... 3\n";
$dbh = DBI->connect("dbi:Oracle:",User."@".DB,Pass) or die $!;

print "Disconnect Oracle Database 10g Express Edition ...\n";
$dbh->disconnect;

Tuesday, September 11, 2012

Perl - USE [ Copy | Move | Constant ]


#!/usr/bin/perl
use strict;
use warnings;

use  File::Copy;
use constant WORK=>'/Users/als/';

copy(WORK."tmp.txt",WORK."tmp.txt.copy") or die "Copy failed $!";

move(WORK."tmp.txt",WORK."Desktop/tmp.txt") or die "Move failed $!";

print "Print constant\t:",WORK;
                           

Monday, September 10, 2012

Perl - [ Create INDEX.HTML ]

 #!/usr/bin/perl
use strict;
use warnings;

&Usage if $#ARGV<0;

my $REGEX = shift;

print "
<html>
    <head>
        <title></title>
        </head>
        <body>
                <center><h1></h1></center>

                                                        ";
foreach my $file (glob ("*.html")){

        my $text = $file;
        $text =~ s/\.$REGEX.*//g;

        print "\t\t<a href=\"$file\">$text</a><br/>\n";
}
print "
        </body>

</html>

";

sub Usage(){

    print "\nUsage: perl CreatePageIndex.pl fastq > index.html\n";
        exit(1);
}

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

-bash-4.0$ ll
total 2356
-rw-r--r-- 1 andre users 326585 2012-09-10 10:57 Phix.sort.bam.html.html
-rw-r--r-- 1 andre users 350366 2012-09-10 10:57 polipo11p.sort.bam.html.html
-rw-r--r-- 1 andre users 336857 2012-09-10 10:57 polipo17p.sort.bam.html.html
-rw-r--r-- 1 andre users 345978 2012-09-10 10:57 polipo45p.sort.bam.html.html
-rw-r--r-- 1 andre users 342493 2012-09-10 10:57 tumor11t.sort.bam.html.html
-rw-r--r-- 1 andre users 344666 2012-09-10 10:57 tumor17t.sort.bam.html.html
-rw-r--r-- 1 andre users 351703 2012-09-10 10:57 tumor45t.sort.bam.html.html
-bash-4.0$perl CreatePageIndex.pl

Usage: perl CreatePageIndex.pl fastq > index.html

-bash-4.0$ perl CreatePageIndex.pl sort

<html>
    <head>
        <title></title>
        </head>
        <body>
                <center><h1></h1></center>

                                                                        <a href="Phix.sort.bam.html.html">Phix</a><br/>
                <a href="polipo11p.sort.bam.html.html">polipo11p</a><br/>
                <a href="polipo17p.sort.bam.html.html">polipo17p</a><br/>
                <a href="polipo45p.sort.bam.html.html">polipo45p</a><br/>
                <a href="tumor11t.sort.bam.html.html">tumor11t</a><br/>
                <a href="tumor17t.sort.bam.html.html">tumor17t</a><br/>
                <a href="tumor45t.sort.bam.html.html">tumor45t</a><br/>

        </body>

</html>

Perl - [ VIM | headers | pl ]


 less ~/.vim/headers/pl

#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;

my ($output_dir,$number,$input_dir);

&Usage("Too few arguments") if $#ARGV<0;

GetOptions(

        'o|out_dir=s'    => \$output_dir,
        'i|input_dir=s'    => \$input_dir,
        'n|number=i'     => \$number

)or &Usage("Wrong arguments");


&process();

sub process(){

        foreach my $file (glob("*.")){

                open(IN,"$file")or die $!;

                while(<IN>){
                        chomp;
                        my @line = split(/\t/,$_);
                        print "$line[1]\n";
                        die;
                }
        }
}

sub Usage(){
       
        my($msg) = @_;
                  
        print "\nUsage: perl script.pl -o out_dir/ -i input_dir/ -n 1
                                       
        $msg!

        Argument(s):   

        -out_dir|-o    
        -number|-n
        -input_dir|-i\n";
        exit(1);
}

Perl [ Net::FTP ]

#!/usr/bin/perl
use strict;
use warnings;

use Net::FTP;

my $ftp = Net::FTP->new("ftp.suse.com", Debug => 0,  Timeout => 3) or die "Cannot connect to ftp.suse.com: $@";

if ( $ftp->login('anonymous','')){

    my @dirs = $ftp->dir();

    foreach my $dir (@dirs){

            my ($permission,$number1,$user,$group,$number2,$months,$day,$year,$name_path) = split(/\s+/,$dir);

            print "Name path:\t$name_path\n";

            my @sub_dir = $ftp->ls("$name_path/*.txt");

            print "Name file *.txt:\t$sub_dir[0]\n";

            my $file_txt = $ftp->get($sub_dir[0]);

            print "Name file GET $file_txt:\t$sub_dir[0]\n";

            print "Copy $file_txt to LocalHost\n";

            `cp $file_txt ftp.txt`;

            $ftp->quit();
    }
}
-----------------------------------------------------------------------------------------------
Result
perl ftp.pl
Name path:      pub
Name file *.txt:        pub/README.txt
Name file GET README.txt:       pub/README.txt
Copy README.txt to LocalHost
less ftp.txt

Thursday, September 6, 2012

Friday, August 24, 2012

Perl - Getopt::Long

#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;

my $output_dir;
my $number_base;

&Usage("Too few arguments") if $#ARGV<0;

GetOptions(

    'o|out_dir=s'    => \$output_dir,
    'b|base=i'     => \$number_base

)or &Usage("Wrong arguments");

sub Usage(){

    my($msg) = @_;

    print "\nUsage: perl CutBaseRead.pl -o out_fir/ -b 40
   
    $msg!

    Argument(s):    -out_dir|-o     -base|-b\n";

    exit(1);
}

Monday, August 20, 2012

Wednesday, August 15, 2012

Mysql - Script Load Table DataBase | Shell

#!/bin/bash

DB_USER="name_user"
PASS="pass_user"
HOST="host_name"
DB="name_dateBase"
TABLE="name_table"
PATH_FOLDER=`pwd`

for file in `ls *.txt`

do
    mysql -u ${DB_USER} -h ${HOST} -p -D ${DB} -e "LOAD DATA LOCAL INFILE '${PATH_FOLDER}/${file}' INTO TABLE ${TABLE} FIELDS TERMINATED BY '\t';"
done

Wednesday, August 8, 2012

Linux - [ Mount - Umount ] / HD EXTERNO

sudo su -l

# fdisk -l

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048   209713151   104855552   83  Linux
/dev/sda2       209713152   226484223     8385536   82  Linux swap / Solaris
/dev/sda3       226484224   976773119   375144448   83  Linux

   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1               1      409639      204819+  ee  GPT
/dev/sdf2          409640   624880263   312235312    7  HPFS/NTFS/exFAT

# mkdir /mnt/hd_tmp

# mount -t vfat dev/sdf2 /mnt/hd_tmp/

# touch /mnt/hd_tmp/tmp.txt

# umount /mnt/hd_tmp/

Tuesday, July 24, 2012

Linux | Awk simple examples


-bash-4.0$ head -n 4 gene_Start_End.gff
chr1    AADACL3 12776344        12788726        +
chr1    AADACL4 12704566        12727097        +
chr1    ABCA4   94458793        94586705        -
chr1    ABCB10  229653926       229694442       -

-bash-4.0$ cat gene_Start_End.gff | awk '{print $1"\t"$3"\t"$4"\t"$2"\t"$5;}' | head -n 4
chr1    12776344        12788726        AADACL3 +
chr1    12704566        12727097        AADACL4 +
chr1    94458793        94586705        ABCA4   -
chr1    229653926       229694442       ABCB10  -

-bash-4.0$

Friday, June 22, 2012

Perl - [FILE CONF / Config::IniFiles ]

configfile.ini
--------------------------------------------------------------------------------------------------------------
 [db]
user = Command Line
pass = 123
--------------------------------------------------------------------------------------------------------------

blog.pl
--------------------------------------------------------------------------------------------------------------
 #!/usr/bin/perl
use strict;
use warnings;
use Config::IniFiles;


my $config = Config::IniFiles->new (-file => "configfile.ini");
my $usr =  $config->val('db','user');
my $pass =  $config->val('db','pass');

print "Name : $usr\tPassword : $pass\n";
--------------------------------------------------------------------------------------------------------------

 Result:
perl blog.pl
Name : Command Line     Password : 123

Tuesday, June 12, 2012

Perl - [ Working with parameter ]

#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;

## setup my defaults
my $name     ;
my $age      ;
my $help     = 0;

GetOptions(
    'n|name=s'    => \$name,
    'a|age=i'     => \$age,
    'help!'     => \$help,

     ) or die "Incorrect usage!\n";

    if( $help ) {
         print "perl script.pl -n blog -a 2\n";
    } else {
        print "My name is $name.\n";
        print "I am $age years old.\n";
    }

-----------------------------------------------------------------------------------------------------------
 :~> perl script.pl -n andre -a 22
My name is andre.
I am 22 years old.

PERL - Validate Palindromo

validate.pl
--------------------------------------------------------------------------------------------------------------
#!/bin/bin/perl
use strict;
use warnings;

my $palavra = shift or die $!;
my @array = split(//,$palavra);

my ($max,$valida) = ($#array,0);

for(my $i = 0; $i <= $#array/2; $i++  ){
    if($array[$i] eq $array[$max]){
           $valida ++;
    }
    $max --;
}

if($valida >=  ($#array/2) ){
    print "@array:\tPalindromo YES\n";
}else{
    print "@array:\tPalindromo NO\n";
}
--------------------------------------------------------------------------------------------------------------
:~> perl validate.pl arara
a r a r a:      Palindromo YES
:~> perl validate.pl arar
a r a r:        Palindromo NO
:~> perl validate.pl tenet
t e n e t:      Palindromo YES
:~> perl validate.pl tene
t e n e:        Palindromo NO

Perl - [ SCRIPT TO BACKUP ]

 backup.pl
------------------------------------------------------------------------------------------------------------
#!/usr/bin/perl
use strict;
use warnings;

my $path = shift or die $!;

my $dir_out = 'backup_Perl';

`mkdir $dir_out`    unless (-e "$dir_out");

print `find $path -name "*.pl" > tmp_path_backup`;

open (IN,"tmp_path_backup") or die $!;

while(<IN>){
    chomp;
    print `cp $_ $dir_out/`;
}

close(IN);

print `rm tmp_path_backup`;

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

$perl backup.pl projects/
-bash-4.0$ ls
Área de trabalho  backup_Perl  backup.pl  Documentos  Downloads  igv  Imagens  Modelos  Música  projects  Público   Vídeos


-bash-4.0$ ls backup_Perl/
annotCDS.pl       convert_1.pl             createTable_new.pl                format_refGeneCDS.pl  getInterestGene.pl  insert_dbSNP.pl             qualitySam.pl          samStatus.pl          tmp.pl
annotSomatic.pl   convert_2.pl             createTable.pl                    frequency.pl          grepCount.pl        insertFall.pl               rand_change2.pl        samTOcsfasta.pl       troca.pl
bamTopileup.pl    countAlleleDefth.pl      create_Triplet.pl                 function_IUPAC.pl     grepTable4.pl       merge_col_HmmMergeDBsnp.pl  rand_change.pl         select_dbSNP.pl       tryTochange.pl
computerFile.pl   countTabla4_1.pl         dif.pl                            geneArray.pl          gretable4.3.pl      merge.pl                    rank_BIOSCOPE_conv.pl  separa.pl
computerIntro.pl  createTable_CDSannot.pl  fasta2stockholm_userHMMSERACH.pl  getFTP.pl             HmmMergeDBsnp.pl    pileupCVR.pl                recorverName.pl        sort_Merge.pl
computer.pl       createTableIndel.pl      formaTOdb.pl                      getInfo.pl            hmm_parser.pl       pipeline.pl                 recover.pl             TESTEannotSomatic.pl

Sunday, June 10, 2012

Friday, June 8, 2012

Mysql && Perl / [ toGenerate_TIME | Show ]

toGenerate_TIME.pl
-------------------------------------------------------------------------------------------------------------------------
#!/usr/bin/perl
use strict;
use warnings;

my $myInterval = shift or die print "Usage : ./toGenerate_TIME.pl 30\n $!";

my $Time_start = 0;

my $Time_stop = 23;

my $interval = 0;

print "create table horas(id int(10) primary key  auto_increment, horario time);\n";

while($Time_start <= $Time_stop){
        if($interval){
                if( $Time_start < 10){
                        print "INSERT INTO horas (horario) VALUES ('0$Time_start:$interval:00');\n";
                }else{
                        print "INSERT INTO horas (horario) VALUES ('$Time_start:$interval:00');\n";
                }
        }else{
                if($Time_start < 10){
                        print "INSERT INTO horas (horario) VALUES ('0$Time_start:00:00');\n";
                }else{
                        print "INSERT INTO horas (horario) VALUES ('$Time_start:00:00');\n";
                }
        }

        $interval += $myInterval;

        if($interval >= 60) {

                $Time_start++;
                $interval = 0;
        }
}
-------------------------------------------------------------------------------------------------------------------------
$ perl toGenerate_TIME.pl 30
create table horas(id int(10) primary key  auto_increment, horario time);
INSERT INTO horas (horario) VALUES ('00:00:00');
INSERT INTO horas (horario) VALUES ('00:30:00');
INSERT INTO horas (horario) VALUES ('01:00:00');
INSERT INTO horas (horario) VALUES ('01:30:00');
INSERT INTO horas (horario) VALUES ('02:00:00');
INSERT INTO horas (horario) VALUES ('02:30:00');
INSERT INTO horas (horario) VALUES ('03:00:00');
INSERT INTO horas (horario) VALUES ('03:30:00');
INSERT INTO horas (horario) VALUES ('04:00:00');
INSERT INTO horas (horario) VALUES ('04:30:00');
INSERT INTO horas (horario) VALUES ('05:00:00');
INSERT INTO horas (horario) VALUES ('05:30:00');
INSERT INTO horas (horario) VALUES ('06:00:00');
INSERT INTO horas (horario) VALUES ('06:30:00');
INSERT INTO horas (horario) VALUES ('07:00:00');
INSERT INTO horas (horario) VALUES ('07:30:00');
INSERT INTO horas (horario) VALUES ('08:00:00');
INSERT INTO horas (horario) VALUES ('08:30:00');
INSERT INTO horas (horario) VALUES ('09:00:00');
INSERT INTO horas (horario) VALUES ('09:30:00');
INSERT INTO horas (horario) VALUES ('10:00:00');
INSERT INTO horas (horario) VALUES ('10:30:00');
INSERT INTO horas (horario) VALUES ('11:00:00');
INSERT INTO horas (horario) VALUES ('11:30:00');
INSERT INTO horas (horario) VALUES ('12:00:00');
INSERT INTO horas (horario) VALUES ('12:30:00');
INSERT INTO horas (horario) VALUES ('13:00:00');
INSERT INTO horas (horario) VALUES ('13:30:00');
INSERT INTO horas (horario) VALUES ('14:00:00');
INSERT INTO horas (horario) VALUES ('14:30:00');
INSERT INTO horas (horario) VALUES ('15:00:00');
INSERT INTO horas (horario) VALUES ('15:30:00');
INSERT INTO horas (horario) VALUES ('16:00:00');
INSERT INTO horas (horario) VALUES ('16:30:00');
INSERT INTO horas (horario) VALUES ('17:00:00');
INSERT INTO horas (horario) VALUES ('17:30:00');
INSERT INTO horas (horario) VALUES ('18:00:00');
INSERT INTO horas (horario) VALUES ('18:30:00');
INSERT INTO horas (horario) VALUES ('19:00:00');
INSERT INTO horas (horario) VALUES ('19:30:00');
INSERT INTO horas (horario) VALUES ('20:00:00');
INSERT INTO horas (horario) VALUES ('20:30:00');
INSERT INTO horas (horario) VALUES ('21:00:00');
INSERT INTO horas (horario) VALUES ('21:30:00');
INSERT INTO horas (horario) VALUES ('22:00:00');
INSERT INTO horas (horario) VALUES ('22:30:00');
INSERT INTO horas (horario) VALUES ('23:00:00');
INSERT INTO horas (horario) VALUES ('23:30:00');


Mysql [ if / else | DATA / TIME ]

Sintaxe : IF(<condition>, <value if true>, <value if false>)



mysql> create table reserva(id int(10) primary key  auto_increment, tempo time, data date);
Query OK, 0 rows affected (0.08 sec)

mysql> desc reserva;
+-------+---------+------+-----+---------+----------------+
| Field | Type    | Null | Key | Default | Extra          |
+-------+---------+------+-----+---------+----------------+
| id    | int(10) | NO   | PRI | NULL    | auto_increment |
| tempo | time    | YES  |     | NULL    |                |
| data  | date    | YES  |     | NULL    |                |
+-------+---------+------+-----+---------+----------------+
3 rows in set (0.04 sec)


mysql> insert into reserva (tempo,data) values (CURTIME(),CURDATE());
Query OK, 1 row affected (0.00 sec)

mysql> insert into reserva (tempo,data) values ('10:33:40','2010-06-10');
Query OK, 1 row affected (0.39 sec)

mysql> insert into reserva (tempo,data) values ('05:43:40','2000-03-10');
Query OK, 1 row affected (0.00 sec)


mysql> select curtime();
+-----------+
| curtime() |
+-----------+
| 00:11:42  |
+-----------+
1 row in set (0.03 sec)

mysql> select * from reserva where id = 1 and if(tempo > curtime() , 1 , 0 );
+----+----------+------------+
| id | tempo    | data       |
+----+----------+------------+
|  1 | 17:33:40 | 2012-06-08 |
+----+----------+------------+
1 row in set (0.00 sec)

mysql> select * from reserva where id = 1 and if(tempo > curtime() , 0 , 1 );
Empty set (0.00 sec)

mysql> select CURDATE();
+------------+
| CURDATE()  |
+------------+
| 2012-06-09 |
+------------+
1 row in set (0.00 sec)

mysql> select * from reserva where id = 1 and if(data < curdate() , 1 , 0 );
+----+----------+------------+
| id | tempo    | data       |
+----+----------+------------+
|  1 | 17:33:40 | 2012-06-08 |
+----+----------+------------+
1 row in set (0.00 sec)

mysql> select * from reserva where id = 1 and if(data < curdate() , 0 , 1 );
Empty set (0.00 sec)

mysql> select * from reserva where id = 1 and if(data > curdate() , 1 , 0 );
Empty set (0.00 sec)

mysql> select * from reserva where id = 1 and if(data > curdate() , 0 , 1 );
+----+----------+------------+
| id | tempo    | data       |
+----+----------+------------+
|  1 | 17:33:40 | 2012-06-08 |
+----+----------+------------+
1 row in set (0.00 sec)