Posts belonging to Category os_command



Neue Version des Betriebssystem-Packages: 1.0.0RC1

New version of operating system package: 1.0.0RC1
Heute habe ich eine neue Version meines Betriebssystem-Packages für PL/SQL veröffentlicht. Und langsam wird es ja auch mal Zeit, die "Nuller"-Versionen hinter sich zu lassen. Für diejenigen, die es noch nicht kennen: In diesem Paket habe ich Funktionen zusammengestellt, die den Zugriff auf das Dateisystem und die Shell vereinfachen. Zwar kann man mit UTL_FILE problemlos Dateien schreiben und lesen, FILE_PKG kann darüber hinaus jedoch Verzeichnisse auslesen - und zwar mit einem SELECT; wie bei einer Tabelle. OS_COMMAND erlaubt das Ausführen von Betriebssystem-Kommandos - und zwar mit vollem Zugriff auf stdin, stdout, stderr und auf den Return Code. Einfach mal ausprobieren ...
Today I released a new version of my operanting system package for PL/SQL. It now time to say goodbye to the "zero" version numbers and introduce version 1. I'll start with a "release candidate". For those not familiar with the package: It allows easy access to the filesystem, to files or to the operating system shell. Reading from or writing to files is possible with UTL_FILE but FILE_PKG allows to get directory listings with a SQL query - the directory is being exposed like a database table! OS_COMMAND allows executing shell commands - with full access to stdin, stdout, stderr and the Return Code. Just give it a try ...
Und das ist im Release 1.0 RC1:
And that is new to Release 1.0 RC1:
  • Die Prozedur FILE_PKG.SET_FS_ENCODING erlaubt es, für Dateinamen mit einem anderen als dem Datenbankzeichensatz zu arbeiten. Das ist hilfreich bei Dateinamen mit Umlauten.
  • Die EXEC-Prozeduren im Package OS_COMMAND können die Ausgaben von "stdout" und "stderr" nun getrennt voneinander verarbeiten.
  • The new procedure FILE_PKG.SET_FS_ENCODING allows to work with different encodings for file names. If filenames contain special characters (umlauts) this is useful.
  • The EXEC procedures in OS_COMMAND are now able to handle "stdout" and "stderr" separately.
Und schließlich habe ich intern ein wenig optimiert. Es ist manchmal immer wieder beeindruckend, was das Erzeugen von Java-Objekten kostet. Im konkreten Fall habe ich den Code so umgestellt, dass einige interne Objekte nicht mehr jedesmal neu, sondern nur einmal erstellt und danach wiederverwendet werden. Das Ergebnis kann sich sehen lassen. Hier ist ein Directory-Listing mit der vorherigen Version 0.9.2.
And last but not least I did some internal optimizations. I saw that I recreated some internal java object for each call - and decided to create them only once and to reuse them afterwards. When I tested the effect I was stunned ... here is a directory listing with the previous version 0.9.2.
SQL> select count(*), sum(file_size) from table(file_pkg.get_file_list(file_pkg.get_file('/usr/bin')))  COUNT(*) SUM(FILE_SIZE)---------- --------------      1287       769761561 Zeile wurde ausgewählt.Abgelaufen: 00:00:07.62
Und hier die neue Version 1.0.0RC1 (gleiche Maschine, gleiche Datenbank, nur anderes Schema):
And this is the listing with new version 1.0.0RC1 (same machine, same database, just other schema):
SQL> select count(*), sum(file_size) from table(file_pkg.get_file_list(file_pkg.get_file('/usr/bin')))  COUNT(*) SUM(FILE_SIZE)---------- --------------      1287       769761561 Zeile wurde ausgewählt.Abgelaufen: 00:00:00.35
Es lohnt sich also auf jeden Fall, die neue Version auszuprobieren. Über Feedback freue ich mich (wie immer).
Just try it out - if you have feedback for the package, let me know ...

Neue Version des Betriebssystem-Packages: 1.0.0RC1

New version of operating system package: 1.0.0RC1
Heute habe ich eine neue Version meines Betriebssystem-Packages für PL/SQL veröffentlicht. Und langsam wird es ja auch mal Zeit, die "Nuller"-Versionen hinter sich zu lassen. Für diejenigen, die es noch nicht kennen: In diesem Paket habe ich Funktionen zusammengestellt, die den Zugriff auf das Dateisystem und die Shell vereinfachen. Zwar kann man mit UTL_FILE problemlos Dateien schreiben und lesen, FILE_PKG kann darüber hinaus jedoch Verzeichnisse auslesen - und zwar mit einem SELECT; wie bei einer Tabelle. OS_COMMAND erlaubt das Ausführen von Betriebssystem-Kommandos - und zwar mit vollem Zugriff auf stdin, stdout, stderr und auf den Return Code. Einfach mal ausprobieren ...
Today I released a new version of my operanting system package for PL/SQL. It now time to say goodbye to the "zero" version numbers and introduce version 1. I'll start with a "release candidate". For those not familiar with the package: It allows easy access to the filesystem, to files or to the operating system shell. Reading from or writing to files is possible with UTL_FILE but FILE_PKG allows to get directory listings with a SQL query - the directory is being exposed like a database table! OS_COMMAND allows executing shell commands - with full access to stdin, stdout, stderr and the Return Code. Just give it a try ...
Und das ist im Release 1.0 RC1:
And that is new to Release 1.0 RC1:
  • Die Prozedur FILE_PKG.SET_FS_ENCODING erlaubt es, für Dateinamen mit einem anderen als dem Datenbankzeichensatz zu arbeiten. Das ist hilfreich bei Dateinamen mit Umlauten.
  • Die EXEC-Prozeduren im Package OS_COMMAND können die Ausgaben von "stdout" und "stderr" nun getrennt voneinander verarbeiten.
  • The new procedure FILE_PKG.SET_FS_ENCODING allows to work with different encodings for file names. If filenames contain special characters (umlauts) this is useful.
  • The EXEC procedures in OS_COMMAND are now able to handle "stdout" and "stderr" separately.
Und schließlich habe ich intern ein wenig optimiert. Es ist manchmal immer wieder beeindruckend, was das Erzeugen von Java-Objekten kostet. Im konkreten Fall habe ich den Code so umgestellt, dass einige interne Objekte nicht mehr jedesmal neu, sondern nur einmal erstellt und danach wiederverwendet werden. Das Ergebnis kann sich sehen lassen. Hier ist ein Directory-Listing mit der vorherigen Version 0.9.2.
And last but not least I did some internal optimizations. I saw that I recreated some internal java object for each call - and decided to create them only once and to reuse them afterwards. When I tested the effect I was stunned ... here is a directory listing with the previous version 0.9.2.
SQL> select count(*), sum(file_size) from table(file_pkg.get_file_list(file_pkg.get_file('/usr/bin')))

  COUNT(*) SUM(FILE_SIZE)
---------- --------------
      1287       76976156

1 Zeile wurde ausgewählt.

Abgelaufen: 00:00:07.62
Und hier die neue Version 1.0.0RC1 (gleiche Maschine, gleiche Datenbank, nur anderes Schema):
And this is the listing with new version 1.0.0RC1 (same machine, same database, just other schema):
SQL> select count(*), sum(file_size) from table(file_pkg.get_file_list(file_pkg.get_file('/usr/bin')))

  COUNT(*) SUM(FILE_SIZE)
---------- --------------
      1287       76976156

1 Zeile wurde ausgewählt.

Abgelaufen: 00:00:00.35
Es lohnt sich also auf jeden Fall, die neue Version auszuprobieren. Über Feedback freue ich mich (wie immer).
Just try it out - if you have feedback for the package, let me know ...

Betriebssystem-Zugriff mit SQL und PLSQL: Neue Version verfügbar

New version 0.9 available: Executing OS commands from the database

Nach über einem Jahr habe ich heute eine neue Version des PL/SQL-Pakets für den Zugriff auf Dateien, Verzeichnisse und Betriebssystem-Kommandos veröffentlicht. Download wie immer über die Projektseite auf sourceforge.net. Neue Features sind:
  • Neue Pipelined Functions für das Listing von Verzeichnisinhalten: Wesentlich bessere Performance
  • Komplexe Shell-Kommandos (besonders auf Unix wichtig) werden nun unterstützt; siehe OS_COMMAND.SET_EXEC_IN_SHELL.
  • Eine SQL Developer-Erweiterung ist nun ebenfalls dabei.
The last version was more than a year ago - today I released the new version 0.9 of my package for file access and operating system interaction. You can download it from the project website at sourceforge.net. Some new features:
  • There are new Pipelined Functions for directory listings - these have better performance and are more memory-efficient.
  • Complex Shell-Commands (which are common on Unix platforms) are now supported - see the OS_COMMAND.SET_EXEC_IN_SHELL call.
  • An extension for Oracle SQL Developer is also included.
Was ist das Besondere an diesem Paket - es gibt doch UTL_FILE? Ganz einfach: Schaut euch das hier an:
Why such a package - there is UTL_FILE? The answer is below:
SQL> select file_name, file_size, last_modified 
  2  from table(file_pkg.get_file_list_p(file_pkg.get_file('/'))) 
  3  order by 1;

FILE_NAME                       FILE_SIZE LAST_MODIFIED
------------------------------ ---------- ----------------
.autofsck                               0 08.02.2010 09:42
bin                                  4096 18.01.2010 18:20
boot                                 1024 18.01.2010 18:17
dev                                  3240 08.02.2010 09:46
etc                                  4096 08.02.2010 09:46
home                                 4096 18.01.2010 18:20
lib                                  4096 18.01.2010 18:20
lost+found                          16384 05.05.2009 20:17
media                                4096 09.01.2009 02:19
misc                                    0 08.02.2010 09:42
mnt                                  4096 09.01.2009 02:19
net                                     0 08.02.2010 09:42
opt                                  4096 08.02.2010 09:43
proc                                    0 08.02.2010 09:41
root                                 4096 08.02.2010 10:16
sbin                                12288 18.01.2010 18:20
selinux                                 0 08.02.2010 09:41
srv                                  4096 09.01.2009 02:19
stage                                   5 10.11.2009 14:10
swapfile                       1610612736 08.02.2010 09:43
sys                                     0 08.02.2010 09:41
tmp                                  4096 08.02.2010 11:16
usr                                  4096 18.01.2010 18:17
var                                  4096 18.01.2010 18:18
wget-log                              495 08.02.2010 09:46

25 Zeilen ausgewählt.
Feedback ist wie immer sehr erwünscht ...
Feedback is very appreciated ...