viernes, 30 de septiembre de 2011

Traducir desde la Consola

Instalamos el paquete:
# apt-get install apertium-en-es


Editamos un archivo y ponemos dentro algo en ingles:
# vim ingles-input.txt
My name is walrus Peter.


Traducimos de ingles a espanol:
# apertium en-es ingles-input.txt > espanol-output.txt


Vemos el texto traducido:
# cat espanol-output.txt
Mi nombre es Peter.


Si queremos traducir de ingles a espanol, simplemente invertimos el en-es por es-en.

Si queremos por ejemplo traducir el man del bash, realizamos lo siguiente:
# man bash > bash-en-ingles.txt
# apertium en-es ingles-input.txt > espanol-output.txt

viernes, 9 de septiembre de 2011

Splunk en Debian 6.0 Squeeze

Descargamos el paquete de splunk desde la pagina, previamente registrandonos:

wget -O splunk-4.2.3-105575-linux-2.6-intel.deb 'http://www.splunk.com/index.php/download_track?file=4.2.3/splunk/linux/splunk-4.2.3-105575-linux-2.6-intel.deb&ac=&wget=true&name=wget&typed=releases'



Instalamos el paquete:

dpkg -i splunk-4.2.3-105575-linux-2.6-intel.deb


Selecting previously deselected package splunk.
(Reading database ... 22518 files and directories currently installed.)
Unpacking splunk (from splunk-4.2.3-105575-linux-2.6-intel.deb) ...
Setting up splunk (4.2.3-105575) ...
----------------------------------------------------------------------
Splunk has been installed in:
/opt/splunk

To start Splunk, run the command:
/opt/splunk/bin/splunk start

To use the Splunk Web interface, point your browser at:
http://192.168.1.1:8000

Complete documentation is at http://www.splunk.com/r/docs
----------------------------------------------------------------------



Iniciamos el splunk:

/opt/splunk/bin/splunk start
Do you agree with this license? [y/n]: y



http://192.168.1.1:8000
user: admin
pass: changeme

Ingresamos nuevo pass: cambiame


Descargamos el Forwarder para el Windows:

Add data
Windows event logs
Download the universal forwarder
splunkforwarder-4.2.2-101277-x86-release.msi
(Cliente para: Windows XP, 2003, Vista, Windows 7, 2008)



Instalacion del Universal Fordwarder:

Next
I accept -> Next -> Next
ip: vacio port: vacio (Default: 8089)
Next
192.168.1.1 (port default: 9997)
Next
Local Data Only
Application log
Next
Install
Finish



Agregamos el puerto en el que recibiremos la data:

Manager » Forwarding and receiving » Receive data » Add New
9997 >> Save



Verificamos que el puerto 9997 esta escuchando en el server:

www:~# netstat -ano | grep 9997
tcp 0 0 0.0.0.0:9997 0.0.0.0:* LISTEN off (0.00/0/0)



En caso de tener un firewall corriendo agregamos las siguientes entradas:

www:~# iptables -A INPUT -s 192.168.1.0/24 -p tcp --dport 9997 -j ACCEPT
www:~# iptables -A INPUT -s 192.168.1.0/24 -p tcp --dport 8000 -j ACCEPT
www:~# iptables -A INPUT -s 192.168.1.0/24 -p tcp --dport 8089 -j ACCEPT

viernes, 2 de septiembre de 2011

Script en Bash hexadecimal a texto - Hexadecimal to text in bash

Input: "data.txt" debe tener formato de a 2 caracteres separados por un enter, por ejemplo:

data.txt:
48 4f 4c 41

Output: "result.txt" tendrá el formato de letras separadas por un enter, por ejemplo la salida del imput previo será:

result.txt:
HOLA


Código en Bash:

#!/bin/bash
for line in $(cat data.txt); do
case $line in
"20") echo -n " " >> ./result.txt
;;
"41") echo -n "A" >> ./result.txt
;;
"42") echo -n "B" >> ./result.txt
;;
"43") echo -n "C" >> ./result.txt
;;
"44") echo -n "D" >> ./result.txt
;;
"45") echo -n "E" >> ./result.txt
;;
"46") echo -n "F" >> ./result.txt
;;
"47") echo -n "G" >> ./result.txt
;;
"48") echo -n "H" >> ./result.txt
;;
"49") echo -n "I" >> ./result.txt
;;
"4a") echo -n "J" >> ./result.txt
;;
"4b") echo -n "K" >> ./result.txt
;;
"4c") echo -n "L" >> ./result.txt
;;
"4d") echo -n "M" >> ./result.txt
;;
"4e") echo -n "N" >> ./result.txt
;;
"4f") echo -n "O" >> ./result.txt
;;
"50") echo -n "P" >> ./result.txt
;;
"51") echo -n "Q" >> ./result.txt
;;
"52") echo -n "R" >> ./result.txt
;;
"53") echo -n "S" >> ./result.txt
;;
"54") echo -n "T" >> ./result.txt
;;
"55") echo -n "U" >> ./result.txt
;;
"56") echo -n "V" >> ./result.txt
;;
"57") echo -n "W" >> ./result.txt
;;
"58") echo -n "X" >> ./result.txt
;;
"59") echo -n "Y" >> ./result.txt
;;
"5a") echo -n "Z" >> ./result.txt
;;
"61")
echo -n "a" >> ./result.txt
;;
"62")
echo -n "b" >> ./result.txt
;;
"63")
echo -n "c" >> ./result.txt
;;
"64")
echo -n "d" >> ./result.txt
;;
"65")
echo -n "e" >> ./result.txt
;;
"66")
echo -n "f" >> ./result.txt
;;
"67")
echo -n "g" >> ./result.txt
;;
"68")
echo -n "h" >> ./result.txt
;;
"69")
echo -n "i" >> ./result.txt
;;
"6a")
echo -n "j" >> ./result.txt
;;
"6b")
echo -n "k" >> ./result.txt
;;
"6c")
echo -n "l" >> ./result.txt
;;
"6d")
echo -n "m" >> ./result.txt
;;
"6e")
echo -n "n" >> ./result.txt
;;
"6f")
echo -n "o" >> ./result.txt
;;
"70")
echo -n "p" >> ./result.txt
;;
"71")
echo -n "q" >> ./result.txt
;;
"72")
echo -n "r" >> ./result.txt
;;
"73")
echo -n "s" >> ./result.txt
;;
"74")
echo -n "t" >> ./result.txt
;;
"75")
echo -n "u" >> ./result.txt
;;
"76")
echo -n "v" >> ./result.txt
;;
"77")
echo -n "w" >> ./result.txt
;;
"78")
echo -n "x" >> ./result.txt
;;
"79")
echo -n "y" >> ./result.txt
;;
"7a")
echo -n "z" >> ./result.txt
;;
*)
echo -n "Valor no encontrado"
;;
esac
done
echo >> ./result.txt