elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.
 
Inicio Ayuda Buscar Ingresar Registrarse
29 Mayo 2012, 06:51  


Tema destacado: [AIO elhacker.NET] Compilación herramientas análisis y desinfección malware

+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting (Moderadores: Novlucker, Leo Gutiérrez., EleKtro H@cker)
| | |-+  [Bash] Mis scripts
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [Bash] Mis scripts  (Leído 1,151 veces)
Leo Gutiérrez.
. . .. ... ..... ........ ............. .....................
Moderador
***
Desconectado Desconectado

Mensajes: 2.968


/^$/


Ver Perfil WWW
[Bash] Mis scripts
« en: 18 Abril 2011, 02:50 »

Eston son algunos de los scripts que uso a diario, bueno, no a diarion, pero son de uso personal, los dejo para ver si a alguien le sirven, que los prueben y vean qué modificaciones se les puede hacer.

space
Código
#!/bin/bash
# Leo Gutiérrez R. leorocko13@hotmail.com
# Script que comprime todos los archivos en el directorio actual.
# Util para hacer espacio en dispositivos extraíbles.
# Uso personal.
find . -type f | while read file
do
extension=`echo "${file}" | awk -F . '{print $NF}'`;
echo -e "$extension" | grep -ie "^\(rar\|Z\|7z\|bz2\|zip\|gz\)$" &> /dev/null && continue;
rar a "${file}.rar" "$file" -y -df
done
 

usb

Código
#!/bin/bash
# Leo Gutiérrez R.
# Script para navegar por sobre los dispositivos USB en el sistema.
# Uso personal.
select archivo in `ls -1 /media/ | grep -v "^cd$" | grep -v "^dvd$" | grep -v "^fl$" | grep -v "^ubuntu$" | grep -v "^windows$"`
do
if [ -n "$archivo" ]
then
cd /media/"$archivo"
break;
else
echo -e "Error eligiendo dispositivo";
exit 1;
fi
done

cdprompt

Código:
[leo@archero ~]$ cdprompt
1) amsn_received/       9) drivers_tia_de_valeria/  17) Musica/        25) Software/
2) bash/      10) escuela/   18) NetBeansProjects/        26) Textos/
3) cpps/      11) guitar/   19) perl/        27) visual/
4) c_proyects/      12) Imagenes/   20) projects/        28) yare/
5) Descargas/      13) java/   21) proyectos/        29) SALIR
6) Desktop/      14) linux/   22) python/
7) Downloads/      15) maiesecuele/   23) respaldo_usb_papa/
8) drivers_cesar/      16) *****/   24) revistas/
>

Código
#!/bin/bash - 
#===============================================================================
#
#          FILE:  cdprompt.sh
#
#         USAGE:  ./cdprompt.sh
#
#   DESCRIPTION:  Cambio de directorios interactivamente.
#
#       OPTIONS:  ---
#  REQUIREMENTS:  ---
#          BUGS:  ---
#         NOTES:  ---
#        AUTHOR: |Leo Gutiérrez R.| (), |leorocko13@hotmail|
#       COMPANY:
#       CREATED: 02/26/2011 01:51:28 AM CST
#      REVISION:  ---
#===============================================================================
 
select directorio in */ "SALIR"
do
if [ "$directorio" = "SALIR" ]
then
break;
elif [[ -n "$directorio" ]]
then
cd "$directorio"
break;
else
echo -e "\aError de opción.";
break;
fi
done
 

rmsecure
Script de borrado interactivo, muestra qué archivos eliminar en el directorio local:

Código:
1) C_Plus_Plus_Varios_Libros.rar  5) PKGBUILD
2) Diagrama_EDGAR.mwb   6) src
3) pacman-3.5.1   7) SALIR
4) pacman-3.5.1.tar.gz
>

Código
#!/bin/bash
# Script de borrado interactivo.
# Leo Gutiérrez Ramírez. leorocko13@hotmail.com
 
function rmsecure()
{
 
select archivos in * "SALIR"
do
if [ "${archivos}" = "SALIR" ]
then
 
exit 0;
 
elif [[ -n "${archivos}" ]]
then
 
sudo rm -rvi "${archivos}" || {
echo -e "Error borrando archivo : ${archivos}";
exit 0;
}
 
clear;
rmsecure;
 
else
 
echo -e "Error eligiendo archivo.";
 
fi
 
done
}
 
clear;
rmsecure;
 

unins.sh
Script para ArchLinux, muestra los paquetes para elegir cuál desinstalar, todo a través de una pequeña interfaz.


Código
#!/bin/bash
 
[ ${UID} != 0 ] && {
echo -e "Se requieren privilegios de Root";
exit 1;
}
 
pacman -Qei | sed -n "s/^Name.*\:\s\(.*\)/\1/p" > nombres.txt
pacman -Qei | sed -n "s/^Version.*\:\s\(.*\)/\1/p" > versiones.txt
 
Xdialog --title "Desinstalar paquetes" --menu "Elija su paquete:" 24 51 6 $(paste nombres.txt versiones.txt) 2> /tmp/menu.tmp.$$
 
retval=$?
choice=`cat /tmp/menu.tmp.$$`
rm -f nombres.txt
rm -f versiones.txt
rm -f /tmp/menu.tmp.$$
 
case "$retval" in
 1)
   exit 0;
   ;;
 255)
   exit 0;
   ;;
esac
 
yes | pacman -R "${choice}" && {
Xdialog --title "Desinatalar paquetes" --msgbox "${choice} desinstalado con éxito." 10 100
} || {
Xdialog --title "Desinatalar paquetes" --msgbox "${choice} no se pudo desinstalar." 10 100
exit 1;
}
 
exit 0;
 

sc

Código
#!/bin/bash
# Leo Gutiérrez R.
# Script para comprobar si un proceso está corriendo.
 
[ $# -ne 1 ] && {
cat <<EOF
 
`basename $0` service
 
EOF

exit 1;
}
 
[ -f "/var/run/daemons/$1" ] && {
echo -e "\"$1\" running.";
} || {
echo -e "\"$1\" stopped.";
}
exit 0;
 

modins


Código
#!/bin/bash
# Script para instalar paquetes en Perl.
 
function getch()
{
OLD_STTY=`stty -g`
stty cbreak -echo
look=`dd if=/dev/tty bs=1 count=1 2>/dev/null`
stty $OLD_STTY
}
 
function installModule()
{
sudo perl Makefile.PL
sudo make
sudo make test
sudo make install
}
 
function modins()
{
archivo=
select archivo in *.tar.gz "SALIR"
do
if [ "${archivo}" = "SALIR" ]
then
 
exit 0;
 
elif [[ -n "${archivo}" ]]
then
 
echo -e "Elegiste : ${archivo}";
tar zxvf "${archivo}" &> /dev/null || {
echo -e "Error descomprimiendo [ ${archivo} ]";
exit 1;
}
 
cd "${archivo%\.tar.gz}" 2> /dev/null || {
echo -e "\aError abriendo directorio ${archivo%%.*}";
exit 1;
}
 
installModule;
 
echo -e "\E[31;47mMódulo instalado. Presione una tecla para continuar.";
tput sgr0;
getch;
break;
 
else
 
echo -e "Error eligiendo archivo.";
exit 0;
 
fi
 
done
}
 
modins;
exit 0;
 

Saludos.


En línea

Código
(( 1 / 0 )) &> /dev/null || {
echo -e "stderrrrrrrrrrrrrrrrrrr";
}
 

leorocko13@hotmail.com
https://github.com/leogtzr/
El_Java

Desconectado Desconectado

Mensajes: 132



Ver Perfil WWW
Re: [Bash] Mis scripts
« Respuesta #1 en: 18 Abril 2011, 11:25 »

Muy buen aporte, si señor!
Te pongo aqui los que yo uso, solo son 2, pero espero que ayuden a alguien :P

Script cambiar de fondo pantalla cada 15 minutos
Código
#!/bin/sh 
 
#Script para cambiar de fondo de escritorio cada 10 minutos
 
 
cd ~/Imagenes/Fondos\ pantalla/
 
while [ 1 ]; do
 
for aux in $(ls) ; do
#echo "gconftool-2 --type string --set /desktop/gnome/background/picture_filename  ~/Imagenes/Fondos\ pantalla/$aux"
sleep 15m
gconftool-2 --type string --set /desktop/gnome/background/picture_filename  ~/Imagenes/Fondos\ pantalla/$aux
done
 
done
 
wait
 
 

Script para abrir JDownloader (Yo lo uso como aplicacion al inicio)
Código
#!/bin/sh 
 
#Cambiar por el directorio donde tengais el JDownloader.jar
 
echo "Ejecuntando JDownloader..."
nohup java -jar /home/java/Escritorio/JDownloader/JDownloader.jar
 
& exit
 

Además, uso otro script que me ejecuta un terminal en mitad de la pantalla transparente al iniciar sesión que queda bastante bien, si os interesa decidmelo xD
Os pongo una imagen:


Un saludo!


En línea
JuszR


Desconectado Desconectado

Mensajes: 2.844


Programming, GNU/Linux & RI


Ver Perfil
Re: [Bash] Mis scripts
« Respuesta #2 en: 18 Abril 2011, 12:23 »

Código
#!/usr/bin/env bash
# Script para extraer archivos
# JuszR gentoo@rocks.net
# GPL
 
 
if [ "$#" -lt 1 ]; then
echo -ne "\n\tUso:"
echo -e "\n\t$(basename $0) <archivo> (.tar, .rar, .bz2...)"
echo ""
exit 1
fi
 
if [ -f $1 ] ; then
       case $1 in
           *.tar.bz2 | *.tbz2)   tar xvjf $1        ;;
           *.tar.gz)    tar xvzf $1     ;;
           *.bz2)       bunzip2 $1       ;;
           *.rar)       unrar x $1     ;;
           *.gz)        gunzip $1     ;;
           *.tar)       tar xvf $1        ;;
           *.tgz)       tar xvzf $1       ;;
           *.zip)       unzip $1     ;;
           *.Z)         uncompress $1  ;;
           *.7z)        7z x $1    ;;
           *)           echo "'$1' no puede ser extraido" ;;
esac
   else
       echo "'$1' no es un archivo valido"
   fi
 

Código
#!/usr/bin/env bash
# Colores en bash
# JuszR gentoo@rocks.net
# GPL
 
# Variables
txtund=$(tput sgr 0 1)          # Subrayado
txtbld=$(tput bold)             # Negrita
bldred=${txtbld}$(tput setaf 1) #  rojo
bldblu=${txtbld}$(tput setaf 4) #  azul
bldwht=${txtbld}$(tput setaf 7) #  blanco
txtrst=$(tput sgr0)             # Resetear
info=${bldwht}*${txtrst}        # Feedback
pass=${bldblu}*${txtrst}
warn=${bldred}!${txtrst}
 
echo
echo -e "$(tput bold) norm  negr  subr   tput-colores$(tput sgr0)"
 
for i in $(seq 1 7); do
 echo " $(tput setaf $i)Texto$(tput sgr0) $(tput bold)$(tput setaf $i)Texto$(tput sgr0) $(tput sgr 0 1)$(tput setaf $i)Texto$(tput sgr0)  \$(tput setaf $i)"
done
 
echo ' Negrita            $(tput bold)'
echo ' Subrayado       $(tput sgr 0 1)'
« Última modificación: 18 Abril 2011, 12:28 por JuszR » En línea

- No programming language is perfect. There is not even a single best language; there are only languages well suited or perhaps poorly suited for particular purposes. [Herbert Mayer]
- GNU/Linux is an alternative, not a replacement. Want a Windows replacement? Buy Mashitosh.
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Scripts
Desarrollo Web
_dark_day_ 1 380 Último mensaje 20 Noviembre 2004, 16:25
por aNexos
Scripts en BASH
Ejercicios
-EvilBuffer- 7 12,791 Último mensaje 23 Febrero 2010, 13:45
por ^Tifa^
Scripts
GNU/Linux
H@T 1 272 Último mensaje 9 Junio 2006, 12:55
por H@T
Scripts
Windows
CarLiLlooo 1 462 Último mensaje 29 Junio 2008, 04:19
por hitori batusai
[Bash script] equivalente de goto en batch para bash (SOLUCIONADO)
Scripting
moikano→@ 4 2,553 Último mensaje 4 Noviembre 2010, 15:58
por moikano→@
Powered by SMF 1.1.16 | SMF © 2006-2008, Simple Machines