quinta-feira, 8 de outubro de 2015

Powershell script to read .csv file and processing each row

1. Introduction

This script shows how to process each line of a .csv file.  Put fields headers in first line.


2. Script

2.1. Sample 'services.csv' input file

servico,login,senha
Spooler,lp0795\tmp,tmp
Themes,lp0795\tmp,tmp
Spooler,lp0795\tmp,tmp


2.2. Script sample

# ##############################################################################
# filename: csv-process.ps1
# author  : josemarsilva@yahoo.com.br
# date    : 2015-10-09
# purpose : Sample script processing each row from a .csv file. First row has
#           fields titles
# pre-reqs: 
#           - Set-ExecutionPolicy Unrestricted
# remarks :
# ############################################
#
$csvFile = "C:\Users\Josemarsilva\Downloads\services.csv"
$bufferRead = Import-Csv $csvFile
foreach ( $line in $bufferRead ) {
    # println fields ...
    "servico = " + $line.servico + "; login = " + $line.login + "; senha=" + $line.senha
    # do whatever you want here! you have each field in $line.<field>
}


2.3. Script output sample

servico = Spooler; login = lp0795\tmp; senha=tmp
servico = Themes; login = lp0795\tmp; senha=tmp
servico = Spooler; login = lp0795\tmp; senha=tmp

terça-feira, 2 de junho de 2015

Usefull tool for your end user query database and export result to Excel

1. Introduction

dbQueryExport is usefull tool to your final end user that does not know SQL, but frequently issues you need of information from your systems. Usually final end user needs the result of a query execution exported in a Excel file. Using dbQueryExport, you can customize command line arguments to pre-setting some options for your end user, like database connection, path-to-sqlfile, etc. And finally, you can create shortcut icons with these command line arguments.

dbQueryExport connect to databases ( Oracle, MySQL, PostgreSQL or any other database throught Jdbc Driver ).

2. Demonstration 

  • Demo #1: Using dbQueryExport to export an Oracle database Query


  • Demo #2: Using dbQueryExport to export a Mysql e database Query


  • Demo #3: Using dbQueryExport to export a PostgreSQL database Query


3. Command line arguments

Usage: dbQueryExport [options]

    -c     Class name for invocation
    -d     Database Url location for Jdbc Driver
    -u     Username Jdbc connection
    -p     Password Jdbc connection
    -f     SQL Query Filename complete path
    -o     Export Filename complete path


Examples:
    dbQueryExport.jar -c oracle.jdbc.driver.OracleDriver -d jdbc:oracle:thin:@localhost:1521:dbname -u username -p password -f "C:\TEMP\sqlquery.sql" -o "C:\TEMP\sqlquery.xls"
    dbQueryExport.jar -c org.postgresql.Driver -d jdbc:postgresql://localhost/dbname -u username -p password -f "C:\TEMP\sqlquery.sql" -o "C:\TEMP\sqlquery.xls"
    dbQueryExport.jar -c com.mysql.jdbc.Driver -d jdbc:mysql://localhost:3306/dbname -u username -p password -f "C:\TEMP\sqlquery.sql" -o "C:\TEMP\sqlquery.xls"

See also:
    http://github.com/josemarsilva/dbQueryExport


4. References


Install OpenLDAP and phpLDAPadmin into Ubuntu 14.04

1. Introduction

This post only gathers information about how to install OpenLdap and phpLdapAdmin into Ubuntu 14.04


2. References




quarta-feira, 29 de abril de 2015

Installing DBDesigner 4.0.5 on Ubuntu (32bits) 14.04 and solving libborqt error

1 Introduction


This post show step-by-step how to install DBDesigner tool into Ubuntu 14.04 32bits


2 Step-by-Step

2.1 Download DBDesigner from fabForce site or download 


Enter site http://fabforce.net/dbdesigner4/ and look for Linux 32bits i386 file. I used this file http://fabforce.net/downloadfile.php?iddownloadfile=2


2.2 Uncompress tar.gz file download


$ cd ~/Downloads/
$ tar -zxvf DBDesigner4.0.5.4.tar.gz 


2.3 Enter DBDesigner subdirectory and try to run it. If the result is an error trying to open sared object "libborqt*.so" then follow the next steps


$ cd DBDesigner4/
$ ./DBDesigner4
libborqt-6.9-qt2.3.so: cannot open shared object file: No such file or directory


2.4 Download library from Kylix and uncompress 


$ cd ~/Downloads/
$ wget http://ufpr.dl.sourceforge.net/sourceforge/kylixlibs/kylixlibs3-borqt-3.0-2.tar.gz
$ tar zxvf kylixlibs3-borqt-3.0-2.tar.gz


2.5 Move correct version of library 'libborqt' to '/usr/lib' and adjust permissions


$ cd kylixlibs3-borqt/
$ sudo mv libborqt-6.9.0-qt2.3.so /usr/lib
$ sudo chown root:root /usr/lib/libborqt-6.9.0-qt2.3.so
$ sudo chmod ugo+r /usr/lib/libborqt-6.9.0-qt2.3.so


2.6 Create a symbolic link from expected file name of library to correct version of library

$ sudo ln -s /usr/lib/libborqt-6.9.0-qt2.3.so /usr/lib/libborqt-6.9-qt2.3.so


2.7 Install another required libraries 'libjpeg62'

$ sudo apt-get install libjpeg62:i386


2.8 Run DBDesigner successfully

$ cd DBDesigner4/
$ ./DBDesigner4



3. References








Installing Oracle XE 10.2 on Linux Ubuntu 32bits 14.04

1. Introduction


This post only gathers information about how to install Oracle XE 10.2 on Linux Ubuntu 32 bits 14.04.


  • Oracle XE database versions 11 and 12 are not available on plataform x86 32bits Linux. You have to install version 10g.


2. References



segunda-feira, 27 de abril de 2015

How to install Rails ( Ruby on Rails ) on Ubuntu 14.04

1. Introduction


This post only gathers information about how to install RAILS ( Ruby on Rails ) on Ubuntu 14.04.


2. Steps

Follow instructions on reference document from GoRails:
  • Install/update dependencies
  • Install Ruby 2.2.1  (recommended)
  • Install RbEnv, RubyBuild, 
  • Configure a SSH Key for Git connnect to GitHub 
  • Install Rails 4.2.0 (recommended)
  • Setting Up MySQL
  • Setting Up PostgreSQL


3. References



sexta-feira, 17 de abril de 2015

How to install PostgreSql 9.4 on Ubuntu Desktop 14.04 (Trusty)

1. Introduction


This post gathers information about installing PostgreSql 9.4 on Linux Ubuntu Desktop 14.04 (Trusty)


2. Step-by-Step

  • Add apt repository
$ sudo vim /etc/apt/sources.list.d/pgdg.list 
# PostgreSQL 9.4 
deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main


  • Import the repository signing key, and update the package lists
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
  sudo apt-key add -
sudo apt-get update


  • Install PostgreSQL
$ sudo apt-get install postgresql-9.4
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  dkms
Use 'apt-get autoremove' to remove it.
The following extra packages will be installed:
  libpq5 pgdg-keyring postgresql-client-9.4 postgresql-client-common
  postgresql-common
Suggested packages:
  oidentd ident-server locales-all postgresql-doc-9.4
The following NEW packages will be installed:
  libpq5 pgdg-keyring postgresql-9.4 postgresql-client-9.4
  postgresql-client-common postgresql-common
0 upgraded, 6 newly installed, 0 to remove and 382 not upgraded.
Need to get 4.921 kB of archives.
After this operation, 23,6 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
  :
* Starting PostgreSQL 9.4 database server                               [ OK ] 


  • Connect to PostgreSQL 9.4 and check basic

$ sudo su - postgres
$ psql 
psql (9.4.1)
Type "help" for help.

postgres=# \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-----------+----------+----------+-------------+-------------+---------------------
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres         
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres         
           |          |          |             |             | postgres=CTc/postgres
(3 rows)
postgres=# select schemaname, count(*) from pg_tables group by schemaname;
     schemaname     | count 
--------------------+-------
 information_schema |     7
 pg_catalog         |    51
(2 rows)





3. References