Juan Garcés

Personal Blog

Instalación OpenLdap

octubre 20th, 2013

Este instructivo está realizado para la instalación de OpenLdap en Linux RedHat.

Para realizar la instalación del servidor ejecutamos:


yum install openldap-servers.i386

Finalizada la instalación, configuramos el archivo /etc/openldap/slapd.conf (podemos usar VIM o el editor que deseen)

Reemplazar con VIM

octubre 15th, 2013

Muchas veces me he visto en la necesidad de reemplazar texto con VIM. Acá dejo una de las formas de hacerlo.

Abrimos el archivo a editar con:


vim archivo

Presionamos ESC y ponemos los dos puntos «:». Luego escribimos la instrucción:


:1,$ s/texto_buscado/texto_reemplazo/g

El 1,$ le indica que debe buscar desde la primera hasta la última línea del archivo. Lo demás es reemplazar «texto_buscado» y «texto_reemplazo» por lo que necesitemos.

Programación de Shell Scripts – Linux

septiembre 10th, 2013

Contenidos

1    Introducción
2    Conceptos
2.1    Shells
2.2    Ejecución
2.3    Estructura
2.4    Formatos
3    Variables
3.1    Variables de Entorno
3.2    Manejo de Strings
3.2.1    String entre comillas simples
3.2.2    String entre comillas dobles
3.2.3    Escape de Caracteres
4    Estructuras de Control
4.1    Condicionales
4.2    Bucles
4.3    Comparación de archivos y variables con el comando test

 

Emails con mailx

marzo 17th, 2013

Con esta función podrás enviar emails utilizando el comando mailx, incluso con archivos adjuntos.

#!/bin/sh

send_email()
{
  #
  # Proceso de parámetros
  #
  DIRECCION="$1"
  ASUNTO=""
  MENSAJE=""
  if [ $# -ge 2 ]; then
    if [ "$2" != "-" ]; then
      ASUNTO="$2"
    fi
  fi
  if [ $# -ge 3 ]; then
    if [ "$3" != "-" ]; then
      MENSAJE="$3"
    fi
  fi
  ADJUNTO=""
  if [ $# -ge 4 ]; then
    if [ "$4" != "-" ]; then
      ADJUNTO="$4"
    fi
  fi
  #
  # Envío del email
  #
  ( echo "$MENSAJE";
    if [ "$ADJUNTO" != "" ]; then
      archivo=`echo $ADJUNTO|cut -d'~' -f1`
      nombre=`echo $ADJUNTO|cut -d'~' -f2`
      if [[ "$archivo" == "$nombre" || "$nombre" == "" ]]; then
        nombre=`basename $archivo`
      fi
      if [ -f "$archivo" ]; then
        uuencode "$archivo" "$nombre";
      fi
    fi;
  ) |  mailx -s "$ASUNTO" "$DIRECCION"
}

send_email "tuemail@tudominio.com" "Asunto del mensaje" "Este es el cuerpo del mensaje" "archivo_adjunto.txt"

Juan Garcés

Personal Blog