-
Installing WebSphere Portal in a local network
Recently I had to setup some WebSphere Portal 6.1 installations in VMWares within a private network. Unfortunately the portal installer aborted with the following message “EJPIC0067E: Portal requires a fully qualified host name that is recoganized by the DNS Server.” Even when adding the fully qualified hostname to the hosts file the installer may still fail with the same message.
The workaround is to disable the hostname check by invoking the portal installer with the following parameter specified: -W nodeHost.active=”False”. You should however only do this for test or development installations. -
Comparing version numbers in Jython / Python
Here comes a function to compare version numbers of e.g. Maven artifacts in Jython / Python.
import re def cmpver(vA, vB): """ Compares two version number strings @param vA: first version string to compare @param vB: second version string to compare @author Sebastian Thomschke @return negative if vA < vB, zero if vA == vB, positive if vA > vB. Examples: >>> cmpver("0", "1") -1 >>> cmpver("1", "0") 1 >>> cmpver("1", "1") 0 >>> cmpver("1.0", "1.0") 0 >>> cmpver("1.0", "1") 0 >>> cmpver("1", "1.0") 0 >>> cmpver("1.1.0", "1.0.1") 1 >>> cmpver("1.0.1", "1.1.1") -1 >>> cmpver("0.3-SNAPSHOT", "0.3") -1 >>> cmpver("0.3", "0.3-SNAPSHOT") 1 >>> cmpver("1.3b", "1.3c") -1 >>> cmpver("1.14b", "1.3c") 1 """ if vA == vB: return 0 def num(s): if s.isdigit(): return int(s) return s seqA = map(num, re.findall('\d+|\w+', vA.replace('-SNAPSHOT', ''))) seqB = map(num, re.findall('\d+|\w+', vB.replace('-SNAPSHOT', ''))) # this is to ensure that 1.0 == 1.0.0 in cmp(..) lenA, lenB = len(seqA), len(seqB) for i in range(lenA, lenB): seqA += (0,) for i in range(lenB, lenA): seqB += (0,) rc = cmp(seqA, seqB) if rc == 0: if vA.endswith('-SNAPSHOT'): return -1 if vB.endswith('-SNAPSHOT'): return 1 return rcTheoretically lines 43 – 49 could be written in a more compact way but using the short circuit evaluations (as below) lead to wrong results – at least in Jython 2.1:
seqa = map(lambda s: s.isdigit() and int(s) or s, re.findall('\d+|\w+', vA.replace('-SNAPSHOT', ''))) seqb = map(lambda s: s.isdigit() and int(s) or s, re.findall('\d+|\w+', vB.replace('-SNAPSHOT', ''))) -
Running TomCat 6 in Debug Mode under Windows
While tracing some problems in one of my grails applications I had the need to do step debugging on a remote Tomcat server. Eventually I came up with the following lines to launch TomCat in debug mode:
@echo off set JPDA_TRANSPORT="dt_socket" set JPDA_ADDRESS="8000" set JPDA_SUSPEND="y" catalina.bat jpda start
Simply create a debug.bat file in TomCat’s bin directory and add these lines.
-
Determine the user who logged on via SSH
Today we had the need to determine the initial id of a user who logged onto a Linux box via SSH and executed the su command. When the su command is issued the effective user is changed and whoami or id commands will report that new user id instead.
For anyone who is interested, that is what we came up to put the initial user id into a variable named ${LOGIN_USER}
LOGIN_USER=`who -m`; LOGIN_USER=${LOGIN_USER%% *}or alternatively
LOGIN_USER=`who -m | cut -d' ' -f1`
-
Lotus Notes [Send only] und [Send and File] Schaltflächen für Outlook 2003
Man kann über Lotus Notes sagen was man möchte, wenn man damit eine Weile gearbeitet hat und auf z.B. Outlook umgestiegen ist/wurde, dann fehlt einem in der Regel doch die eine oder andere liebgewonnene Funktion.
Da ich nun bereits bei meinem zweiten Kunden “gezwungen” bin, mit MS Outlook 2003 zu arbeiten und mich scheinbar auch in Zukunft nicht um dessen Verwendung drücken kann, habe ich zwei der vielen praktische Notes-Funktionen für Outlook 2003 implementiert:
- Die Schaltfläche [Send only], bzw. [Nur senden] versendet eine E-Mail ohne eine Kopie davon in Outlook zu speichern.
- Die Schaltfläche [Send and File...] bzw. [Senden und ablegen...] erfragt vor dem Versenden in welchem Ordner die gerade geschriebene E-Mail abgelegt werden soll.
Installation:
- Download des Visual Basic Moduls in der gewünschten Sprache.
Send Mail Macros for MS Outlook 2003 (EN) (4.9 KiB, 1,576 hits)
Send Mail Macros for MS Outlook 2003 (DE) (5.1 KiB, 747 hits)
- In Outlook den Visual Basic Editor öffnen.
- Das Visual Basic Modul importieren
- Das Projekt speichern.
- Die Schaltflächen in der Toolbar installieren.
- Beim Erstellen einer neuen E-Mail sollten nun in der Toolbar die beiden zusätzlichen Schaltflächen angezeigt werden.
- Beim Klick auf “Senden und ablegen…” erscheint vor dem Versenden der Ordnerdialog.
-
getpass für Jython
In meinem aktuellen Projekt entwickle ich u.a. verschiedene Jython basierte Kommandozeilenanwendungen. Einige davon erwarten die Eingabe von maskierten Passwörtern. Python stellt hierfür das getpass Modul bereit. Leider ist bisher keine entsprechende Implementierung für Jython verfügbar.
Im folgenden ein passendes Modul, welches diese Funktionalität bereitstellt. Es verwendet einen Mechanismus um die Passworteingabe in der Kommandozeile zu maskieren, welcher hier beschrieben wurde http://java.sun.com/developer/technicalArticles/Security/pwordmask/. Sollte Jython in Verbindung mit Java 6 oder höher eingesetzt werden, so nutzt dieses Modul stattdessen die neue Console.readPassword() Methode. Sollte das Modul in einer Umgebung laufen in welcher eine getpass Modulimplementierung verfügbar ist, dann wird stattdessen an die entsprechende Methode im getpass Modul delegiert.
# ext_getpass.py # @author Sebastian Thomschke, http://sebthom.de/ import thread, sys, time, os # exposed methods: __all__ = ["getpass","getuser"] def __doMasking(stream): __doMasking.stop = 0 while not __doMasking.stop: stream.write("b*") stream.flush() time.sleep(0.01) def generic_getpass(prompt="Password: ", stream=None): if not stream: stream = sys.stderr prompt = str(prompt) if prompt: stream.write(prompt) stream.flush() thread.start_new_thread(__doMasking, (stream,)) password = raw_input() __doMasking.stop = 1 return password def generic_getuser(): for name in ('LOGNAME', 'USER', 'LNAME', 'USERNAME'): usr = os.environ.get(name) if usr: return usr def java6_getpass(prompt="Password: ", stream=None): if not stream: stream = sys.stderr prompt = str(prompt) if prompt: stream.write(prompt) stream.flush() from java.lang import System console = System.console() if console == None: return generic_getpass(prompt, stream) else: return "".join(console.readPassword()) try: # trying to use Python's getpass implementation import getpass getpass = getpass.getpass getuser = getpass.getuser except ImportError, e: getuser = generic_getuser # trying to use Java 6's Console.readPassword() implementation try: from java.io import Console getpass = java6_getpass except ImportError, e: # use the generic getpass implementation getpass = generic_getpassHere is an usage example:
import ext_getpass as getpass pw = getpass.getpass("Please enter your password:") print "The entered password was: " + pw


Looking for a high performer for your next IT project?








![Schaltfläche [Senden und ablegen...] installieren Schaltfläche [Senden und ablegen...] installieren](http://sebthom.de/wp-content/uploads/2009/02/07_marco_select_install_sendandfile-150x150.png)
![Schaltfläche [Senden und ablegen...] installiert Schaltfläche [Senden und ablegen...] installiert](http://sebthom.de/wp-content/uploads/2009/02/08_msg_sendandfile_installed-150x120.png)
![Schaltfläche [Nur senden] installieren Schaltfläche [Nur senden] installieren](http://sebthom.de/wp-content/uploads/2009/02/09_marco_select_install_sendonly-150x150.png)
![Schaltfläche [Nur senden] installiert Schaltfläche [Nur senden] installiert](http://sebthom.de/wp-content/uploads/2009/02/10_msg_sendonly_installed-150x120.png)


English
Deutsch
Recent Comments