Ismael Olea — web personal
Acerca de

«Producir y nutrir,
producir y no poseer,
obrar y no retener,
acrecentar y no regir,
son el misterio de la vida.
»

Lao Tse hablando de procomunes en el siglo VI ac.

How to use XPath expressions in shell scripting using xmllint

2012-04-04 00:00:00 +0200

This is a minor tip I want to share. A little example of a nice software feature that made my day.

I've been messing with HTML scrapping and I took a look on xmllint (maybe new) features. My intention was to extract a particular pattern, for which the --xpath option could be fine. I've never been very good tuning xpath expressions so I made a search about how to approach this. I found an amazing feature of the xmllint shell mode. As explanation here I show the workflow used:

  • get your document, I used and HTML one
  • I didn't tested with broken HTML but you can test it with xmllint --html
  • get into shell: xmllint --html --shell [document], keep in mind [document] can be a remote URI.
  • in the shell mode you can search for a precise string, in my case I chose the one inside the desired pattern: grep [string]
  • here is when magic happens: xmllint answers with the xpath expression you can use for a xpath query
  • exit the shell
  • copy the extracted xpath expression to CLI: xmllint --html --xpath [xpath]
  • here it is.

You can tune your expressions adding new predicates, as using specific attributes, or extracting the text() node, etc.

Enjoy.

RetroShare for Fedora

2012-03-06 00:00:00 +0100

I've made a pretty dirty porting of the RetroShare package from Unity Linux for Fedora. It's not published in my repository until a minimal QA could be done. You can download it using this interin URI: http://olea.org/tmp/retroshare/retroshare-0.5.2a-2.i686.rpm

Caveats:

  • it's build in F16
  • SPEC source still needs love, so there is a weird dependency error forcing to install with the --nodeps flag
  • I didn't have the time to run it yet, so maybe it's not even operative

You can report me any issue through the comments bellow.

Acceder a notificaciones.060.es con Fedora

2012-02-27 00:00:00 +0100

A la hora de acceder al servicio de notificaciones oficiales de la administración pública española me he encontrado un problema con el uso de applet java con funciones criptográficas.

Mi configuración de partida consistía en

  • java-1.6.0-openjdk-1.6.0.0-65.1.11.1.fc16.i686.rpm
  • icedtea-web-1.1.4-4.fc16.i686.rpm

siendo icedtea-web el plugin java para navegadores (vía NPAPI) oficial de openjdk. No soy un gran usuario de applet vía web pero hasta ahora no recuerdo haber tenido ningún problema. Supongo que en este caso la clave está en los servicios criptográficos X.509.

Tras varias investigaciones esta es la configuración que me ha funcionado

  • Oracle JDK (en sabor RPM)
  • Scientific Linux java-1.6.0-sun-compat
  • he mantenido java-1.6.0-openjdk como alternativa java principal, lo cual es independiente del funcionamiento del plugin del original Oracle
  • adición de certificados X.509 a la infraestructura java de usuario (los applet no saben manejarlos desde el almacén del navegador) con ControlPanel:
    • [Seguridad]->[Certificados]->[CA de firmante]->[Importar]-> fichero FNMTClase2CA.crt
    • [Seguridad]->[Certificados]->[Autenticación de cliente]->[Importar] -> fichero con su certificado FNMT.
  • prueba de compatibilidad: enlace desde la especificación de requisitos de acceso.

Al acceder al certificado digital java pedirá la contraseña de protección que es exactamente la misma que tenía en el fichero importado.

Tras verificar el funcionamiento correcto he podido acceder a las notificaciones que tenía pendientes en notificaciones.060.es.

Ni con la configuración java afinada Chrome pasa la prueba (google-chrome-stable-17.0.963.56-121963).

Los usuarios de applet con funciones criptográficas que no usen servicios basados en certificados de la FNMT pueden encontrar útil la configuración general.

Lecciones aprendidas

  • El plugin de java ahora se llama libnpjp2.so, aunque siguen distribuyendo libjavaplugin_oji.so por motivos que desconozco. Me ha hecho perder una preciosa y enorme cantidad de tiempo con pruebas frustrantes.
  • Para los usuarios Fedora (y entiendo que CentOS, RHEL, etc) parece que tenemos la mejor manera de integrar el JDK oficial de Oracle a través del paquete java-1.6.0-sun-compat de Scientific Linux. Antes usaba la adaptación de JPackage java-1.6.0-sun pero creo que ya es innecesaria aparte de desactualizada.
  • Ismael Olea — web personal
  •  

Pastoreando procomunes desde 1994 — Shepherding the commons since 1994

This website runs on green hosting - verified by thegreenwebfoundation.org GPDR friendly statistics