Posts tagged script
How to capitalize letters on bash shell script
1It’s easy just use the tr command to lower, upper or capital case.
Here is an example…
1 2 3 4 5 6 7 8 9 | function toCapital { for x in $* do echo -n ${x:0:1} | tr '[a-z]' '[A-Z]' | xargs echo -n echo -n ${x:1} | tr '[A-Z]' '[a-z]' | xargs echo -n echo -n " " done } |
To test the function just call it:
1 | toCapital yuCa aMigo |
The output is:
Yuca Amigo
Hope it’s useful.
ASSP & AVG Antivirus Integration Script
0The following script uses the configuration section “ClamAV and FileScan” from ASSP (http://assp.sourceforge.net/) where it is configurated an external script for virus scanning, in this case AVG (http://www.avg.com).
Note that you must download its free version (free.avg.com) or purchase and install it for Linux!!!.
Before enter configuration parameters you must install the downloaded AVG for Linux in Debian (.deb) with the command:
1 | dpkg -i <package>.deb |
The you must enter in “ClamAV and FileScan” configuration section in ASSP the following parameters:
File Scan Directory (FileScanDir): /var/opt/ASSP/virusscan
File Scan Command (FileScanCMD): File Scan Command (FileScanCMD)
RegEx to Detect ‘BAD’ in Returned String* (FileScanBad): BAD
RegEx to Detect ‘GOOD’ in Returned String* (FileScanGood): GOOD
FileScan Reponds Regex (FileScanRespRe):
The logs for this script will be located at /var/log/assp-avg.log
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | #!/bin/bash ### # ARCHIVO: /root/scripts/avg.sh (03/08/2010) # AUTOR: Olaf Reitmaier Veracierta (olafrv@gmail.com) # USO: # Script utilizado por ASSP segun los configurado en la seccion # "ClamAV and File Scan", donde se configura un script externo # para el escaneo de virus, en este caso AVG en su version FREE. # # Antes de configurar los parámetros en ASSP se debe instalar con # el comando dpkg -i el paquete para GNU/Linux Debian del antivirus # AVG disponible en: free.avg.com # Para instalar AVG se descarga el paquete de 32 bits desde la # pagina principal free.avg.com/ y se instala con "dpkg -i" # # Parametros en ASSP (Seccion "ClamAV and File Scan"): # File Scan Directory (FileScanDir): /var/opt/ASSP/virusscan # File Scan Command (FileScanCMD): File Scan Command (FileScanCMD) # RegEx to Detect 'BAD' in Returned String* (FileScanBad): BAD # RegEx to Detect 'GOOD' in Returned String* (FileScanGood): GOOD # FileScan Reponds Regex (FileScanRespRe): # # Los registro de depuracion y errores estan en la ruta # de instalacion de ASSP especificamente en /var/log/assp-avg.log ## # *** SI DESEA NO SCANEAR / CONTINGENCIA!!! *** # echo "GOOD"; exit # *** SI DESEA NO SCANEAR / CONTINGENCIA!!! *** if [ -z "$1" ] then echo "BAD"; exit fi servidor=`hostname` origen=$1 nombre=`basename $origen` logdir=/var/log log=$logdir/assp-avg.log if [ -f "$origen" ] then subject=`cat $origen | grep "^Subject:"` from=`cat $origen | grep "^From:"` to=`cat $origen | grep "^To:"` ret=`avgscan $origen >/dev/null 2>&1; echo $?` if [ $ret -eq 0 ] then echo "GOOD" echo "$origen [GOOD] $subject" >> $log echo "$from" >> $log echo "$to" >> $log echo >> $log else echo "BAD" echo "$origen [BAD] $subject" >> $log echo "$from" >> $log echo "$to" >> $log echo >> $log fi fi |
QEMU script for virtual machine creation and emulation
01 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | #!/bin/sh ### # FILE: # qemu.sh # # DESCRIPTION: # Virtual machine creation and emulation # # AUTHOR: # Olaf Reitmaier <olafrv@gmail.com> (20/07/2009) # # HOW-TO: # Put this on you /etc/network/interfaces # if the real NIC in configured via dhcp: # # auto lo # iface lo inet loopback # # auto eth1 # # auto br0 # iface br0 inet dhcp # bridge_ports eth1 # # Put this on you /etc/network/interfaces if # the real NIC in configured with and static IP: # # auto lo # iface lo inet loopback # # auto eth1 # # auto br0 # iface br0 inet static # address 172.26.98.50 # netmask 255.255.248.0 # gateway 172.26.96.1 # bridge_ports eth1 # # # Then execute the following commands: # cp qemu.sh ~ # apt-get install -y bridge-utils and kqemu-common kqemu-source # cd /usr/src/ # bzip2 -d kqemu.tar.bzip2 # tar xvf kqemu.tar # cd modules/kqemu # ./configure && make && make install # cd ~ # sudo ./qemu.sh ## echo Moving display export DISPLAY=:0.0 echo Loading acceleration kernel module modprobe kqemu echo Verifying hard disk image if ! [ -f hda.img ]; then echo Creating hda.img qemu-img create hda.img 20G fi echo Verifying virtual net device if ! [ -a /dev/net/tun ]; then echo Creating /dev/net/tun mknod /dev/net/tun c 10 200 fi echo To boot from a CD/DVD image or disk put echo this on qemu options but one "-cdrom" echo line showed bellow echo -boot d \ echo -cdrom /dev/cdrom \ echo -cdrom cd.iso \ echo Starting VM emulation qemu -m 256 \ -k es \ -net nic,vlan=0 \ -net tap,vlan=0,ifname=tap0 \ -hda hda.img \ -boot c \ -cdrom /dev/cdrom \ -usb \ -usbdevice "host:04a9:1900" \ -localtime & echo Wainting VM boot and tap0 to appears sleep 30s echo Enabling tap0 /sbin/ifconfig tap0 0.0.0.0 promisc up echo Adding tap0 to br0 /usr/sbin/brctl addif br0 tap0 |