raccolta script

Una delle cose più utili è la possibilità di avere uno script sul tasto destro del mouse.

Ovviamente  tutti conoscono la fantastica raccolta di http://g-scripts.sourceforge.net/

(personalmente la renderei obbligatoria :-)

Oppure la serie di NScripts     http://gnome-look.org/content/show.php/NScripts?content=67655

Ma c’è una serie di script che nel tempo mi son accorto di usare più di altri e che per un banale errore l’altro giorno ho cancellato.

Per cui prima di perderli un’altra volta me li segno qui.

Non tutti gli script hanno la licenza e/o chi li ha fatti ma che io sappia son tutti rilasciati sotto gpl.

 

—————————————————–

#!/bin/bash
# cartellacondata.sh
mkdir “`date +%Y_%m_%d__%H_%M_%S`”

—————————————————–
#!/bin/bash
#  dividifilexquant.sh
## dati 1000K files in una direcoty
## genera n cartelle partendo da 0 e sposta MAX files nelle sotto cartelle
## posizionarsi nella cartella con cd
#  CONTROLLARE ATTENTAMENTE IN QUALE CARTELLA VIENE LANCIATO

i=0
max=50
dirname=1
mkdir $dirname

for file in *; do
if [ ! -d "$file" ]; then
if [ "$i" -ge "$max" ]
then
(( i = 0 ))
(( dirname= $dirname + 1 ))
mkdir $dirname
fi
mv “$file” “$dirname/”
(( i= $i +1))
fi
done

—————————————————–
#!/bin/bash
# generacaratteri.sh
for i in `seq 30 256`; do printf \\x`echo “obase=16; $i” | bc`\\n ; done > ~/Scrivania/testcaratteri.txt

—————————————————–
#!/bin/bash
# html-index.sh
# Script che scandisce un albero di directory e crea un file html
# di indice in ogni sottodirectory

# Stefano Salvi <stefano@salvi.mn.it>
# this file is available under the GNU general public license

# controlla che ci sia un parametro e che questo corrisponda ad una directory
if [ ! "$1" ]
then
echo “Devi indicare la directory nella quale fare l’indice”
exit 1
fi
if [ ! -d "$1" ]
then
echo “$1 non e’ una directory”
exit 2
fi

# Stampa una riga di tabella con il link ad una directory o file da vedere
# $1 -> File
# $2 -> Descrizione
# $3 -> Link
# $4 -> Azione
function view {
# produce la riga di tabella
echo “<tr><td>$1</td><td align=\”center\”>$2</td><td align=\”center\”><a href=\”$3\”>$4</a></td></tr>”
}

# Stampa una riga di tabella con il link ad un file da scaricare
# $1 -> File
# $2 -> Descrizione
# $3 -> File con i caratteri corretti per il Web
function download {
# lista il file (ls), ne estrae la dimensione (awk) e inserisce i punti (sed)
DIMENSIONE=`ls -l “$1″ | awk ‘{ print $5 }’ | \
sed -e “s/\([0-9]\)\([0-9][0-9][0-9]\)$/\1.\2/” -e “s/\([0-9]\)\([0-9][0-9][0-9]\.\)/\1.\2/”`
# Stampa la riga della tabella
echo “<tr><td>$1</td><td align=\”center\”>$2</td><td align=\”center\”><a href=\”$3\”>scarica</a> ($DIMENSIONE byte)</td></tr>”
}

# Stampa un file “index.html”; ricorsivamente, si richiama e redirige il
# risultato sugli “index.html” delle sottodirectory
# Parametri:
# $1 -> percorso corrrente (titolo)
# $2 -> locazione directory corrente (per CD)
function index {
# Dichiara due directory “locali”, cioe’ diverse per ogni invocazione
# della funzione
local OLDPWD
# Recupera il percorso precedente, per tornarci
OLDPWD=`pwd`

# Entra nella directory indicata
cd “$2″

# Stampa la testata del file HTML (html molto grezzo)
echo “<html>”
echo “<head>”
echo “<title>Files in $1</title>”
echo “<body>”
echo “<h1 align=\”center\”>Files in $1</h1>”
echo “<p align=\”center\”>[<a href=\"../index.html\">Directory Superiore</a>]</p>”
echo “<table border=\”1\” align=\”center\”>”

# Fa’ un ciclo sui nomi dei file della directory idicata (corrente)
for f in *
do
# Corregge il nome file
FILE=`echo “$f” | \
sed -e “s/ /%20/g” -e “s/\//%5f/g”`
# Se il file corrente e’ una directory
if [ -d "$f" ]
then
# Produce la figa di tabella che vi rimanda
view “$f” “[Directory]” “$FILE/index.html” “entra”
# si richiama ricorsivamente, per generarne l’indice
index $1/$f $f > $f/index.html
# Altrimenti (e’ un file) se e’ “index.html” (se stesso)
elif [ "$f" = "index.html" ]
then
#l’index stesso – non lo lista
echo “<!– Index.html saltato –>”
else
# estrae l’estensione del file
ESTENSIONE=`echo $f | /bin/sed “s/^.*\.\([^.]*\)$/\1/”`
# se l’estensione coincide con il file,
# il file non ha estensione
if [ "$ESTENSIONE" = "$f" ]
then
ESTENSIONE=”senza tipo”
fi
# In base all’estensione….
case $ESTENSIONE in
htm | html)
view “$f” “Pagina WEB” “$FILE” “Leggi”
;;
txt)
view “$f” “Documento di testo” “$FILE” “Leggi”
;;
*)
download “$f” “file $ESTENSIONE” “$FILE”
;;
esac
fi
done

# stampa la coda del file HTML
echo “</table>”
echo “</body>”
echo “</html>”

# Ritorna alla directory precedente
cd $OLDPWD
}

# richiama la funzione che produce l’indice principale dell’archivio
# e lo immagazzina nel file indice della directory
index “Archivio” $1 > $1/index.html

—————————————————–
#!/bin/bash
#dipendenze yad (http://code.google.com/p/yad/)
ddove=$(yad –file –directory –width=800 –height=600) ## imposta la cartella
if [ $? == 0 ]; then  ## ciclo di controllo che fa uscire se non viene impostata la cartella
risul1=$(find $ddove/ -type f -exec cat {} \; | md5sum )  ## calolo md5
yad –image “dialog-label” –title “Risultato” –button=gtk-yes:0 –button=gtk-no:1 –text  “$risul1″ –selectable-labels  ## fa vedere il risultato
fi

—————————————————–
#!/bin/bash
#copiaverso.sh
#########################################################
#                            #
# This are NScripts v3.4                #
#                            #
# Licensed under the GNU GENERAL PUBLIC LICENSE 3    #
#                            #
# Copyright 2007 – 2008 Christopher Bratusek        #
#                            #
#########################################################

if [[ -x /usr/bin/gksu || -x /opt/gnome/bin/gksu ]]; then
sudotool=”gksu -u root”
elif [[ -x /usr/bin/gnomesu || -x /opt/gnome/bin/gnomesu ]]; then
sudotool=gnomesu
fi

destination=$(zenity –file-selection –directory –title “Where to copy files?”)

echo $NAUTILUS_SCRIPT_SELECTED_URIS > ~/.gnome2/temp_copy_list

for file in $(cat ~/.gnome2/temp_copy_list); do \

file_name=$(echo $file | sed -e ‘s/file:\/\///g’ -e ‘s/\%20/\ /g’)
short_file_name=$(echo $file | sed -e ‘s#.*/##g’ -e ‘s/\%20/\ /g’)

if [[ -w $destination && -a $destination/$short_file_name ]]; then \
confirm=$(zenity zenity –question –text “Overwrite File $destination/$short_file_name?”; echo $?)
if [[ $confirm == 0 ]]; then
cp -r “$file_name” $destination
if (( $? != 0 )); then
zenity –info –text “Something went wrong” –title “Failure”
fi
fi
elif [[ -w $destination ]]; then \
cp -r “$file_name” $destination
if (( $? != 0 )); then
zenity –info –text “Something went wrong” –title “Failure”
fi
elif [[ -a $destination && $sudotool != "" ]]; then
$sudotool “cp -r ‘$file_name’ $destination”
else    zenity –info –title “Failure” –text “$destination does either not\nexist or is not writable”
fi; \
done

rm -f ~/.gnome2/temp_copy_list

—————————————————–
#!/bin/bash
#muoviverso.sh
#########################################################
#                            #
# This are NScripts v3.4                #
#                            #
# Licensed under the GNU GENERAL PUBLIC LICENSE 3    #
#                            #
# Copyright 2007 – 2008 Christopher Bratusek        #
#                            #
#########################################################

if [[ -x /usr/bin/gksu || -x /opt/gnome/bin/gksu ]]; then
sudotool=”gksu -u root”
elif [[ -x /usr/bin/gnomesu || -x /opt/gnome/bin/gnomesu ]]; then
sudotool=gnomesu
fi

destination=$(zenity –file-selection –directory –title “Where to move files?”)

echo $NAUTILUS_SCRIPT_SELECTED_URIS > ~/.gnome2/temp_move_list

for file in $(cat ~/.gnome2/temp_move_list); do \

file_name=$(echo $file | sed -e ‘s/file:\/\///g’ -e ‘s/\%20/\ /g’)
short_file_name=$(echo $file | sed -e ‘s#.*/##g’ -e ‘s/\%20/\ /g’)

if [[ -w $destination && -a $destination/$short_file_name ]]; then \
confirm=$(zenity zenity –question –text “Overwrite File $destination/$short_file_name?”; echo $?)
if [[ $confirm == 0 ]]; then
mv “$file_name” $destination
if (( $? != 0 )); then
zenity –info –text “Something went wrong” –title “Failure”
fi
fi
elif [[ -w $destination ]]; then \
mv “$file_name” $destination
if (( $? != 0 )); then
zenity –info –text “Something went wrong” –title “Failure”
fi
elif [[ -a $destination && $sudotool != "" ]]; then
$sudotool “mv ‘$file_name’ $destination”
else    zenity –info –title “Failure” –text “$destination does either not\nexist or is not writable”
fi; \
done

rm -f ~/.gnome2/temp_move_list

—————————————————–
#!/bin/bash
#rendieseguibile.sh

for arg; do
chmod u+x — “$arg”
done

—————————————————–
#!/bin/bash
# start-server.sh
#Autore script: Mattia Castiglione
#Sito: http://c2asr.altervista.org
#Codice ipext preso da http://gnome-look.org/content/show.php/conky+meet+faenza?content=133086&PHPSESSID=5079a66bbea4381783f1927de73db023

ipext=$(wget http://checkip.dyndns.org/ -q -O – |grep -Eo ‘\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>’);

porta=$(zenity –entry –text “Scrivere la porta del server (default: 8000)” –entry-text “8000″);

exec xterm -T “Log server HTTP” -e python -m SimpleHTTPServer $porta & zenity –question –text “Server HTTP attivato con successo!\nIndirizzo interno: http://localhost:$porta\nIndirizzo esterno: http://$ipext:$porta\nCLICCARE SI-NO PER DISABILITARE ILSERVER”

if [ $? -eq 0]
then
pkill xterm
else
pkill xterm
fi

 

 

 

 

#!/bin/bash
mkdir “`date +%Y_%m_%d__%H_%M_%S`”
#!/bin/bash
## dati 1000K files in una direcoty
##  genera n cartelle partendo da 0 e sposta MAX files nelle sotto cartelle
## posizionarsi nella cartella con cd
i=0
max=50
dirname=1
mkdir $dirname

for file in *; do
if [ ! -d "$file" ]; then
if [ "$i" -ge "$max" ]
then
(( i = 0 ))
(( dirname= $dirname + 1 ))
mkdir $dirname
fi
mv “$file” “$dirname/”
(( i= $i +1))
fi
done

#!/bin/bash
for i in `seq 30 256`; do printf \\x`echo “obase=16; $i” | bc`\\n ; done > /home/ugone/Scrivania/testcaratteri.txt

#!/bin/bash
# html-index
# Script che scandisce un albero di directory e crea un file html
# di indice in ogni sottodirectory

# Stefano Salvi <stefano@salvi.mn.it>
# this file is available under the GNU general public license

# controlla che ci sia un parametro e che questo corrisponda ad una directory
if [ ! "$1" ]
then
echo “Devi indicare la directory nella quale fare l’indice”
exit 1
fi
if [ ! -d "$1" ]
then
echo “$1 non e’ una directory”
exit 2
fi

# Stampa una riga di tabella con il link ad una directory o file da vedere
# $1 -> File
# $2 -> Descrizione
# $3 -> Link
# $4 -> Azione
function view {
# produce la riga di tabella
echo “<tr><td>$1</td><td align=\”center\”>$2</td><td align=\”center\”><a href=\”$3\”>$4</a></td></tr>”
}

# Stampa una riga di tabella con il link ad un file da scaricare
# $1 -> File
# $2 -> Descrizione
# $3 -> File con i caratteri corretti per il Web
function download {
# lista il file (ls), ne estrae la dimensione (awk) e inserisce i punti (sed)
DIMENSIONE=`ls -l “$1″ | awk ‘{ print $5 }’ | \
sed -e “s/\([0-9]\)\([0-9][0-9][0-9]\)$/\1.\2/” -e “s/\([0-9]\)\([0-9][0-9][0-9]\.\)/\1.\2/”`
# Stampa la riga della tabella
echo “<tr><td>$1</td><td align=\”center\”>$2</td><td align=\”center\”><a href=\”$3\”>scarica</a> ($DIMENSIONE byte)</td></tr>”
}

# Stampa un file “index.html”; ricorsivamente, si richiama e redirige il
# risultato sugli “index.html” delle sottodirectory
# Parametri:
# $1 -> percorso corrrente (titolo)
# $2 -> locazione directory corrente (per CD)
function index {
# Dichiara due directory “locali”, cioe’ diverse per ogni invocazione
# della funzione
local OLDPWD
# Recupera il percorso precedente, per tornarci
OLDPWD=`pwd`

# Entra nella directory indicata
cd “$2″

# Stampa la testata del file HTML (html molto grezzo)
echo “<html>”
echo “<head>”
echo “<title>Files in $1</title>”
echo “<body>”
echo “<h1 align=\”center\”>Files in $1</h1>”
echo “<p align=\”center\”>[<a href=\"../index.html\">Directory Superiore</a>]</p>”
echo “<table border=\”1\” align=\”center\”>”

# Fa’ un ciclo sui nomi dei file della directory idicata (corrente)
for f in *
do
# Corregge il nome file
FILE=`echo “$f” | \
sed -e “s/ /%20/g” -e “s/\//%5f/g”`
# Se il file corrente e’ una directory
if [ -d "$f" ]
then
# Produce la figa di tabella che vi rimanda
view “$f” “[Directory]” “$FILE/index.html” “entra”
# si richiama ricorsivamente, per generarne l’indice
index $1/$f $f > $f/index.html
# Altrimenti (e’ un file) se e’ “index.html” (se stesso)
elif [ "$f" = "index.html" ]
then
#l’index stesso – non lo lista
echo “<!– Index.html saltato –>”
else
# estrae l’estensione del file
ESTENSIONE=`echo $f | /bin/sed “s/^.*\.\([^.]*\)$/\1/”`
# se l’estensione coincide con il file,
# il file non ha estensione
if [ "$ESTENSIONE" = "$f" ]
then
ESTENSIONE=”senza tipo”
fi
# In base all’estensione….
case $ESTENSIONE in
htm | html)
view “$f” “Pagina WEB” “$FILE” “Leggi”
;;
txt)
view “$f” “Documento di testo” “$FILE” “Leggi”
;;
*)
download “$f” “file $ESTENSIONE” “$FILE”
;;
esac
fi
done

# stampa la coda del file HTML
echo “</table>”
echo “</body>”
echo “</html>”

# Ritorna alla directory precedente
cd $OLDPWD
}

# richiama la funzione che produce l’indice principale dell’archivio
# e lo immagazzina nel file indice della directory
index “Archivio” $1 > $1/index.html

#!/bin/bash
ddove=$(yad –file –directory –width=800 –height=600) ## imposta la cartella
if [ $? == 0 ]; then  ## ciclo di controllo che fa uscire se non viene impostata la cartella
risul1=$(find $ddove/ -type f -exec cat {} \; | md5sum )  ## calolo md5
yad –image “dialog-label” –title “Risultato” –button=gtk-yes:0 –button=gtk-no:1 –text  “$risul1″ –selectable-labels  ## fa vedere il risultato
fi
#!/bin/bash
#########################################################
#                            #
# This are NScripts v3.4                #
#                            #
# Licensed under the GNU GENERAL PUBLIC LICENSE 3    #
#                            #
# Copyright 2007 – 2008 Christopher Bratusek        #
#                            #
#########################################################

if [[ -x /usr/bin/gksu || -x /opt/gnome/bin/gksu ]]; then
sudotool=”gksu -u root”
elif [[ -x /usr/bin/gnomesu || -x /opt/gnome/bin/gnomesu ]]; then
sudotool=gnomesu
fi

destination=$(zenity –file-selection –directory –title “Where to copy files?”)

echo $NAUTILUS_SCRIPT_SELECTED_URIS > ~/.gnome2/temp_copy_list

for file in $(cat ~/.gnome2/temp_copy_list); do \

file_name=$(echo $file | sed -e ‘s/file:\/\///g’ -e ‘s/\%20/\ /g’)
short_file_name=$(echo $file | sed -e ‘s#.*/##g’ -e ‘s/\%20/\ /g’)

if [[ -w $destination && -a $destination/$short_file_name ]]; then \
confirm=$(zenity zenity –question –text “Overwrite File $destination/$short_file_name?”; echo $?)
if [[ $confirm == 0 ]]; then
cp -r “$file_name” $destination
if (( $? != 0 )); then
zenity –info –text “Something went wrong” –title “Failure”
fi
fi
elif [[ -w $destination ]]; then \
cp -r “$file_name” $destination
if (( $? != 0 )); then
zenity –info –text “Something went wrong” –title “Failure”
fi
elif [[ -a $destination && $sudotool != "" ]]; then
$sudotool “cp -r ‘$file_name’ $destination”
else    zenity –info –title “Failure” –text “$destination does either not\nexist or is not writable”
fi; \
done

rm -f ~/.gnome2/temp_copy_list
#!/bin/bash
#########################################################
#                            #
# This are NScripts v3.4                #
#                            #
# Licensed under the GNU GENERAL PUBLIC LICENSE 3    #
#                            #
# Copyright 2007 – 2008 Christopher Bratusek        #
#                            #
#########################################################

if [[ -x /usr/bin/gksu || -x /opt/gnome/bin/gksu ]]; then
sudotool=”gksu -u root”
elif [[ -x /usr/bin/gnomesu || -x /opt/gnome/bin/gnomesu ]]; then
sudotool=gnomesu
fi

destination=$(zenity –file-selection –directory –title “Where to move files?”)

echo $NAUTILUS_SCRIPT_SELECTED_URIS > ~/.gnome2/temp_move_list

for file in $(cat ~/.gnome2/temp_move_list); do \

file_name=$(echo $file | sed -e ‘s/file:\/\///g’ -e ‘s/\%20/\ /g’)
short_file_name=$(echo $file | sed -e ‘s#.*/##g’ -e ‘s/\%20/\ /g’)

if [[ -w $destination && -a $destination/$short_file_name ]]; then \
confirm=$(zenity zenity –question –text “Overwrite File $destination/$short_file_name?”; echo $?)
if [[ $confirm == 0 ]]; then
mv “$file_name” $destination
if (( $? != 0 )); then
zenity –info –text “Something went wrong” –title “Failure”
fi
fi
elif [[ -w $destination ]]; then \
mv “$file_name” $destination
if (( $? != 0 )); then
zenity –info –text “Something went wrong” –title “Failure”
fi
elif [[ -a $destination && $sudotool != "" ]]; then
$sudotool “mv ‘$file_name’ $destination”
else    zenity –info –title “Failure” –text “$destination does either not\nexist or is not writable”
fi; \
done

rm -f ~/.gnome2/temp_move_list
#!/bin/bash
for arg; do
chmod u+x — “$arg”
done
#!/bin/bash

#Autore script: Mattia Castiglione
#Sito: http://c2asr.altervista.org
#Codice ipext preso da http://gnome-look.org/content/show.php/conky+meet+faenza?content=133086&PHPSESSID=5079a66bbea4381783f1927de73db023

ipext=$(wget http://checkip.dyndns.org/ -q -O – |grep -Eo ‘\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>’);

porta=$(zenity –entry –text “Scrivere la porta del server (default: 8000)” –entry-text “8000″);

exec xterm -T “Log server HTTP” -e python -m SimpleHTTPServer $porta & zenity –question –text “Server HTTP attivato con successo!\nIndirizzo interno: http://localhost:$porta\nIndirizzo esterno: http://$ipext:$porta\nCLICCARE SI-NO PER DISABILITARE ILSERVER”

if [ $? -eq 0]
then
pkill xterm
else
pkill xterm
fi

About these ads

Iscriviti

Ricevi al tuo indirizzo email tutti i nuovi post del sito.

%d bloggers like this: