<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[script zenity UBUNTU]]></title><description><![CDATA[<p dir="auto">Vi invio lo script zenity_file.sh a cui bisogna dare in fase d'installazione il comando</p>
<h1>chmod +x /path installazione/zenity.sh</h1>
<p dir="auto">per renderlo eseguibile in una shell da root.<br />
In sintesi e' un file manager per UBUNTU/DEBIAN utilizzante applicativo zenity gia' compreso almeno in UBUNTU 8.04.<br />
Fatemi sapere se siete interessati ad altri script analoghi e i vostri commenti e suggerimenti.<br />
#!/bin/bash<br />
if [ $USER != "root" ]<br />
then<br />
clear<br />
echo "Script eseguibile solo da root"<br />
exit<br />
fi<br />
if [ "$editor" = "" ];then<br />
editor1=<code>which gedit</code><br />
editor2=<code>which kedit</code><br />
editor3=<code>which mcedit</code><br />
editor4=<code>which vi</code><br />
editor=""<br />
if [ "$editor1" ];then<br />
editor="gedit"<br />
elif [ "$editor2" ];then<br />
editor="gedit"<br />
elif [ "$editor3" ];then<br />
editor="luit -encoding ISO-8859-1 mcedit"<br />
elif [ "$editor4" ];then<br />
editor="vi"<br />
else<br />
editor="less"<br />
fi<br />
fi<br />
#----------------------------------------------------------------------</p>
<p dir="auto">errore () {<br />
<a href="/hashtags/chiamare">#chiamare</a> con descrizione errore e dare subito dopo continue se in un ciclo<br />
zenity --error --text="$1"<br />
}</p>
<p dir="auto">avviso () {<br />
<a href="/hashtags/chiamare">#chiamare</a> con testo messaggio<br />
zenity --info --text="$1"<br />
}<br />
domanda () {<br />
<a href="/hashtags/chiamare">#chiamare</a> con testo domanda<br />
zenity --question --text "$1"<br />
return $?<br />
}</p>
<p dir="auto">backup_file () {<br />
<a href="/hashtags/chiamare">#chiamare</a> con pathname completo<br />
if cp -p $1 $1.backup;then<br />
avviso "E' stata creata una copia di "$1" in "$1.backup""<br />
else<br />
errore "Non e' stata creata la copia di "$1""<br />
fi<br />
}</p>
<p dir="auto">rename_file () {</p>
<h1>chiamare con pathname completo</h1>
<p dir="auto">local dir_file="$(dirname "$1")"<br />
local old_name="$(basename "$1")"<br />
local new_name=""<br />
if new_name=<code>zenity --entry --width=300 --title="Rename file" --text="Inserisci il nome del nuovo file" --entry-text="$old_name"</code>;then<br />
<a href="/hashtags/sostituisce">#sostituisce</a> spazi nel nome file con carattere _<br />
new_name=<code>echo "$new_name" | sed "s/[^a-zA-Z0-9_-]/_/g"</code><br />
if [ -e "$dir_file/$new_name" ];then<br />
avviso "Il nome richiesto, "$new_name" e` gia` assegnato a un documento esistente"<br />
else<br />
if mv -f "$1" "$dir_file/$new_name";then<br />
avviso "$old_name cambiato in $new_name"<br />
else<br />
errore "$old_name NON CAMBIATO!"<br />
fi<br />
fi<br />
else<br />
errore "Errore nella funzione"<br />
fi<br />
}</p>
<p dir="auto">delete_file () {<br />
<a href="/hashtags/chiamato">#chiamato</a> con pathname completo<br />
local file_name="$(basename "$1")"<br />
domanda "Vuoi cancellare il file "$file_name?"<br />
if [ "$?" -eq 0 ];then<br />
if rm -f "$1";then<br />
avviso "$file_name cancellato"<br />
else<br />
avviso "$file_name NON CANCELLATO!"<br />
fi<br />
fi<br />
}</p>
<p dir="auto">function permessi_file (){</p>
<h1>chiamata con pathname completo</h1>
<p dir="auto">old_permessi=<code>ls -l $1 | cut -c2-10</code><br />
proprietario=<code>ls -l $1 | cut -f3 -d" "</code><br />
gruppo=<code>ls -l $1 | cut -f4 -d" "</code><br />
c=0<br />
lista=""<br />
tipo=""<br />
while [  $c -lt 9 ]; do<br />
i=<code>echo "${old_permessi:c:1}"</code><br />
case $c in<br />
0)tipo="letturaProprietario";;<br />
1)tipo="scritturaProprietario";;<br />
2)tipo="esecuzioneProprietario";;<br />
3)tipo="letturaGruppo";;<br />
4)tipo="scritturaGruppo";;<br />
5)tipo="esecuzioneGruppo";;<br />
6)tipo="letturaAltri";;<br />
7)tipo="scritturaAltri";;<br />
8)tipo="esecuzioneAltri";;<br />
esac<br />
if [ $i != "-" ];then<br />
i="TRUE "$tipo" "<br />
else<br />
i="FALSE "$tipo" "<br />
fi<br />
lista+=$i<br />
let c=c+1<br />
done<br />
if ans=$(zenity  --list  --text "Permessi del file:$old_permessi\nProprietario: $proprietario\nGruppo: $gruppo\nPremi SPAZIO per mettere/togliere un permesso.\nClicca su OK per terminare" --checklist  --column "Pick" --column "permessi" $lista --separator " ");then<br />
permessi_user=("u=" "-" "-" "-")<br />
permessi_gruppo=("g=" "-" "-" "-")<br />
permessi_altri=("o=" "-" "-" "-")<br />
for letto in $ans;do<br />
if [ $letto = ""letturaProprietario"" ];then<br />
permessi_user[1]="r"<br />
elif [ "$letto" = ""scritturaProprietario"" ];then<br />
permessi_user[2]="w"<br />
elif [ "$letto" = ""esecuzioneProprietario"" ];then<br />
permessi_user[3]="x"<br />
elif [ "$letto" = ""letturaGruppo"" ];then<br />
permessi_gruppo[1]="r"<br />
elif [ "$letto" = ""scritturaGruppo"" ];then<br />
permessi_gruppo[2]="w"<br />
elif [ "$letto" = ""esecuzioneGruppo"" ];then<br />
permessi_gruppo[3]="x"<br />
elif [ "$letto" = ""letturaAltri"" ];then<br />
permessi_altri[1]="r"<br />
elif [ "$letto" = ""scritturaAltri"" ];then<br />
permessi_altri[2]="w"<br />
elif [ "$letto" = ""esecuzioneAltri"" ];then<br />
permessi_altri[3]="x"<br />
fi<br />
done<br />
permessi_user=<code>echo "${permessi_user[@]}"</code><br />
permessi_gruppo=<code>echo "${permessi_gruppo[@]}"</code><br />
permessi_altri=<code>echo "${permessi_altri[@]}"</code></p>
<p dir="auto">permessi_user=<code>echo ${permessi_user//-/}</code><br />
permessi_user=<code>echo ${permessi_user// /}</code><br />
permessi_gruppo=<code>echo ${permessi_gruppo//-/}</code><br />
permessi_gruppo=<code>echo ${permessi_gruppo// /}</code><br />
permessi_altri=<code>echo ${permessi_altri//-/}</code><br />
permessi_altri=<code>echo ${permessi_altri// /}</code><br />
domanda "Vuoi sostituire\nVecchi permessi: $old_permessi \ncon\n Nuovi permessi: $permessi_user $permessi_gruppo $permessi_altri \n?"<br />
case $? in<br />
0)chmod $permessi_user $1;chmod $permessi_gruppo $1;chmod $permessi_altri $1;break;;<br />
esac<br />
fi<br />
return<br />
}</p>
<p dir="auto">function select_opz_file (){</p>
<h1>chiamata con nome file, pathname completo ed ultimo carattere del file</h1>
<p dir="auto">if [ "$3" = "@" ];then<br />
d=$(ls -l "$2")<br />
<a href="/hashtags/trova">#trova</a> ultimo campo con separatore spazio<br />
link_file=${d##* }<br />
avviso "$dir_init$fileread e' un Link a\n$link_file"<br />
return<br />
fi<br />
opzioni="false Backup_file false Rinomina_file false Cancella_file false Permessi_file false Visualizza_in_pannello false Apri_file"</p>
<p dir="auto">if [ "$3" = "*" -o "$3" = "h" ];then<br />
opzioni="false Backup_file false Rinomina_file false Cancella_file false Permessi_file false Visualizza_in_pannello false Apri_file false Lancia_file"<br />
fi<br />
nome_file=$(basename "$2")<br />
menu=<code>zenity --title "Opzioni file $nome_file" --list --radiolist --column=" " --column="fai una scelta" $opzioni</code><br />
while true; do<br />
case $menu in<br />
Backup_file)backup_file "$2";break;;<br />
Rinomina_file)rename_file "$2";break;;<br />
Cancella_file)delete_file "$2";break;;<br />
Permessi_file)permessi_file "$2";break;;<br />
Visualizza_in_pannello)<br />
zenity --text-info --width 630 --title="Visualizza $1" --filename="$2" ;break;;<br />
Apri_file)clear;<code>$editor $2</code> 2&gt; /dev/null;break;;<br />
Lancia_file)<br />
if [ "$3" = "h" ];then<br />
x-www-browser "$2" 2&gt; /dev/null<br />
break<br />
else<br />
clear<br />
bash "$2"<br />
break<br />
fi<br />
;;<br />
*)break<br />
esac<br />
done<br />
return<br />
}</p>
<p dir="auto">function select_file (){<br />
while true; do<br />
if path_fileread=$(zenity --file-selection --separator=$);then<br />
fileread=$(basename $path_fileread)<br />
i=$(ls -F $path_fileread)<br />
l_string=${#i}<br />
# tiene conto che la posizione dei caratteri nella stringa parte da 0<br />
l_string=<code>expr $l_string - 1</code><br />
ultimo_car=${i:l_string:1}<br />
estensione=${fileread##*.}<br />
if [ "$estensione" = "html" -o "$estensione" = "htm" ];then<br />
ultimo_car="h"<br />
fi<br />
select_opz_file "$fileread" "$path_fileread" "$ultimo_car"<br />
else<br />
break<br />
fi<br />
done<br />
}</p>
<p dir="auto">select_file</p>
]]></description><link>https://dev.connect.gt/topic/82473/script-zenity-ubuntu</link><generator>RSS for Node</generator><lastBuildDate>Thu, 26 Nov 2026 06:26:59 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/82473.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 14 Sep 2008 10:45:14 GMT</pubDate><ttl>60</ttl></channel></rss>