Génial.
C'est celà
#!/bin/bash
# Nom du nouveau répertoire
NV_DOSSIER=reduc
echo 'dossier'
echo $1
cd "$1"
# Création du nouveau dossier s'il n'existe pas
if [ -d $NV_DOSSIER ] ;
then
echo "Le dossier reduc existe déjà"
else
mkdir $NV_DOSSIER
fi
rep=$(pwd)
jourmois=$(date +'%d%m')
rep="${rep##*/}"
rep="${rep// /-}"
# Pour toutes les photos (JPG) du répertoire
for image in *[jJ][pP][gG] ;
do
width=$(identify -format '%w' "$image")
height=$(identify -format '%h' "$image")
ratio=$(echo "scale=2; $height / $width" |bc)
echo $ratio
if [ $ratio '<' .70 ]
then
image="${image##*/}"
nv_nom=$(printf '%s_%s_%s\n' ${rep} ${jourmois} $image) #on dit merci à Fred
# Réduit l'image en 601x400
convert "$image" -resize 601x400 "$NV_DOSSIER/$nv_nom"
# fusione l'image avec un calque contenant les coins
composite -gravity center /home/sacha/Images/cadre.png "$NV_DOSSIER/$nv_nom" "$NV_DOSSIER/$nv_nom"
# fin de la boucle FOR
else
nv_nom=$(printf 'thai_prod_%s_%s.jpg\n' ${rep} ${jourmois}) #on dit merci à Fred
# Réduit l'image en 601x400
convert "$image" -resize 200x150 "$NV_DOSSIER/$nv_nom"
# fusione l'image avec un calque contenant les coins
composite -gravity center /home/sacha/Images/cadremini.png "$NV_DOSSIER/$nv_nom" "$NV_DOSSIER/$nv_nom"
fi
done
echo '-Fini !!!'
exit
Bah le saisie de l'adresse ne s'arrete pas à l'espace mais c'est le cd qui s'arrete à l'espace:
mon code:
Exec=reduc.sh "%f"
et echo 'origin'
echo $1
rep_courant="${1// /\ }"
echo 'rep_courant'
echo $rep_courant
echo 'cd1'
cd $rep_courant
echo 'cd2'
cd '$rep_courant'
echo 'cd3'
cd "$rep_courant"
echo 'cd4'
cd $($rep_courant)
Resultat:
origin
/home/sacha/test image
rep_courant
/home/sacha/test\ image
cd1
/bin/reduc.sh: line 11: cd: /home/sacha/test\: Aucun fichier ou répertoire de ce type
cd2
/bin/reduc.sh: line 13: cd: $rep_courant: Aucun fichier ou répertoire de ce type
cd3
/bin/reduc.sh: line 15: cd: /home/sacha/test\ image: Aucun fichier ou répertoire de ce type
cd4
/bin/reduc.sh: line 17: /home/sacha/test\: Aucun fichier ou répertoire de ce type
Le dossier reduc existe déjà
Il apparait bien sous konqueror, mais il ne s'execute pas.
J'ai donc tester en lancant konqueror via la console, pour voir les eventuelle message d'erreur et là ca fonctionne.
Vous auriez une idée pourquoi mon script ne fonctionne qu'a partir konqueror lancer via une console?
# Création du nouveau dossier s'il n'existe pas
if [ -d $NV_DOSSIER ] ;
then
echo "Le dossier reduc existe déjà"
else
mkdir $NV_DOSSIER
fi
rep=$(pwd)
jourmois=$(date +'%d%m')
# Pour toutes les photos (JPG) du répertoire
for image in *[jJ][pP][gG] ;
do
rep="${rep##*/}"
rep="${rep// /-}"
width=$(identify -format '%w' "$image")
height=$(identify -format '%h' "$image")
ratio=$(echo "scale=2; $height / $width" |bc)
echo $ratio
if [ $ratio '<' .70 ]
then
image="${image##*/}"
nv_nom=$(printf '%s_%s_%s\n' ${rep} ${jourmois} $image) #on dit merci à Fred
# Réduit l'image en 601x400
convert "$image" -resize 601x400 "$NV_DOSSIER/$nv_nom"
# fusione l'image avec un calque contenant les coins
composite -gravity center /home/sacha/Bureau/cadre.png "$NV_DOSSIER/$nv_nom" "$NV_DOSSIER/$nv_nom"
# fin de la boucle FOR
else
nv_nom=$(printf 'thai_prod_%s_%s.jpg\n' ${rep} ${jourmois}) #on dit merci à Fred
# Réduit l'image en 601x400
convert "$image" -resize 200x150 "$NV_DOSSIER/$nv_nom"
# fusione l'image avec un calque contenant les coins
composite -gravity center /home/sacha/Bureau/cadremini.png "$NV_DOSSIER/$nv_nom" "$NV_DOSSIER/$nv_nom"
fi
done
et voiçi ma nouvelle version:
# Nom du nouveau répertoire
NV_DOSSIER=reduc
# Création du nouveau dossier s'il n'existe pas
if [ -d $NV_DOSSIER ] ;
then
echo "Le dossier reduc existe déjà"
else
mkdir $NV_DOSSIER
fi
rep=$(pwd)
num=1
jourmois=$(date +'%d%m')
# Pour toutes les photos produit (JPG) du répertoire nommé 1.JPG,2.JPG....
for image in [123456789].[jJ][pP][gG] ;
do
((++num))
# rep="${image%/*}"
rep="${rep##*/}"
rep="${rep// /-}"
image="${image##*/}"
nv_nom=$(printf '%s_%s_%s\n' ${rep} ${jourmois} $image) #on dit merci à Fred
# Réduit l'image en 601x400
convert "$image" -resize 601x400 "$NV_DOSSIER/$nv_nom"
# fusione l'image avec un calque contenant les coins
composite -gravity center /home/sacha/Bureau/cadre.png "$NV_DOSSIER/$nv_nom" "$NV_DOSSIER/$nv_nom"
# fin de la boucle FOR
done
# Pour toutes les photos producteur (JPG) du répertoire nommé prod.JPG
rep=$(pwd)
image=''
nv_nom=''
for image in prod.[jJ][pP][gG] ;
do
((++num))
# rep="${image%/*}"
rep="${rep##*/}"
rep="${rep// /-}"
image="${image##*/}"
nv_nom=$(printf 'thai_prod_%s_%s.jpg\n' ${rep} ${jourmois}) #on dit merci à Fred
# Réduit l'image en 601x400
convert "$image" -resize 200x150 "$NV_DOSSIER/$nv_nom"
# fusione l'image avec un calque contenant les coins
composite -gravity center /home/sacha/Bureau/cadremini.png "$NV_DOSSIER/$nv_nom" "$NV_DOSSIER/$nv_nom"
# fin de la boucle FOR
done
J'ai réussit a faire les deux boucles en une.
cependant j'en ai rajouter une, car j'ai deux type d'image
1- produit 1.JPG, 2.JPG 2816x1880px
2-producteur prod.JPG 2272x1704px
et que la 1- est réduite en 601x400
et la 2 en 200x150
cependant au lieu de tester par le nom de l'image serait il possible de tester par le ration d'image?
D'autant plus que j'ai deux type d'image
produit/producteur
avec des tailles différentes, et des noms différents
Du coup, pour l'instant ca me fais 4 boucles... et c'est horriblement long.
Mais j'y travaille et je vous présente celà dès que j'ai fini.
# Création du nouveau dossier s'il n'existe pas
if [ -d $NV_DOSSIER ] ;
then
echo "Le dossier reduc existe déjà"
else
mkdir $NV_DOSSIER
fi
# Pour toutes les photos (JPG) du répertoire
for i in *.[jJ][pP][gG] ;
do
# Réduit l'image en 601x400
convert "$i" -resize 601x400 "$NV_DOSSIER/$i"
# fusione l'image avec un calque contenant les coins
composite -gravity center /home/sacha/Bureau/cadre.png "$NV_DOSSIER/$i" "$NV_DOSSIER/$i"
# fin de la boucle FOR
done
rep=$(pwd)
cd "$NV_DOSSIER"
# mise a zero (1) du compteur
num=1
jourmois=$(date +'%d%m')
for image in "$rep"/*[jJ][pP][gG]; do
((++num))
rep="${image%/*}"
rep="${rep##*/}"
rep="${rep// /_}"
image="${image##*/}"
nv_nom=$(printf '%s_%s_%.4d_%s\n' ${rep} ${jourmois} ${num} $image) #on dit merci à Fred
mv "$image" $nv_nom
done
mais moi j'ai un créer un scriptnew.sh
cd "/home/sacha/Bureau/image test"
name=${basename "$(pwd)"}
name=${name// /_}
echo $name
et ca me donne:
[sacha@localhost ~/Bureau/image test]$ scriptnew.sh
/bin/scriptnew.sh: line 2: ${basename "$(pwd)"}: bad substitution
et si j'essaye
cd "/home/sacha/Bureau/image test"
name=$(basename $(pwd))
name=${name// /_}
echo $name
ca me donne:
[sacha@localhost ~/Bureau/image test]$ scriptnew.sh
image
avec:
name=basename "$(pwd)"
==> /bin/scriptnew.sh: line 2: /home/sacha/Bureau/image test: is a directory
name=basename $(pwd)
==>/bin/scriptnew.sh: line 2: /home/sacha/Bureau/image: Aucun fichier ou répertoire de ce type
Solution apporté par Yvelan72 sur un autre forum:
[quote]Dans l'absolu, si tu veux lancer un script monscript.sh en sudo sans mot de passe, il y a une solution simple :
Tu crées ton script que tu places quelque part, par exemple dans /home/moi/
Puis visudo
- dans la ligne # Cmnd alias specification tu mets :
[CODE]
# Cmnd alias specification
Cmnd_Alias SCRIPT = /home/moi/monscript.sh[/CODE]
- Tu ajoutes le groupe wheel à ton utilisateur (toi ..)
- et tu décommentes la ligne
[CODE]
# %wheel ALL=(ALL) NOPASSWD: ALL[/CODE]
Visudo:
# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
# Failure to use 'visudo' may result in syntax or file permission errors
# that prevent sudo from running.
#
# See the sudoers man page for the details on how to write a sudoers file.
#
#login ALL=(root) NOPASSWD:/etc/init.d/httpd, /etc/init.d/mysqld
# Host alias specification
# User alias specification
User_Alias STAFF=sacha
# Cmnd alias specification
# Defaults specification
# Runas alias specification
#test
#login ALL=(root) NOPASSWD:/etc/init.d/httpd, /etc/init.d/mysqld
# User privilege specification
root ALL=(ALL) ALL
STAFF ALL=(ALL) ALL
# Uncomment to allow people in group wheel to run all commands
# %wheel ALL=(ALL) ALL
# Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL
#%STAFF ALL=(root) NOPASSWD:/etc/init.d/httpd, /etc/init.d/mysqld
j'ai ensuite créer un fichier /bin/allumageapache.sh
dans lequel j'ai rajouter: #!/bin/bash
/etc/init.d/httpd start
/etc/init.d/mysqld start
puis adapter les droits du script
enfin je lance la commande sudo allumageapache.sh
et il me demande dans tout les cas le mot de passe sans message d'erreur.
P.S.: un trouve plusieurs fois la ligne #login ALL=(root) NOPASSWD:/etc/init.d/httpd, /etc/init.d/mysqld
ce sont les différents endroit ou j'ai essayé.
j'ai aussi essayé: %STAFF ALL=(root) NOPASSWD:/etc/init.d/httpd, /etc/init.d/mysqld
enfin si j'esssaye sans sudo: [sacha@localhost ~]$ allumageapache.sh
Starting httpd: (13)Permission denied: make_sock: could not bind to address 127.0.0.1:80
no listening sockets available, shutting down
Unable to open logs
[�CHEC ]
ls: ne peut ouvrir le r�pertoire /var/lib/mysql/mysql: Permission non accord�e
Initializing MySQL database:
Installing MySQL system tables...
091202 19:20:22 [Warning] Can't create test file /var/lib/mysql/localhost.lower-test
091202 19:20:22 [Warning] Can't create test file /var/lib/mysql/localhost.lower-test
091202 19:20:22 [Warning] One can only use the --user switch if running as root
ERROR: 1347 'mysql.db' is not BASE TABLE
091202 19:20:22 [ERROR] Aborting
Examine the logs in /var/lib/mysql for more information.
You can try to start the mysqld daemon with:
/usr/sbin/mysqld --skip-grant &
and use the command line tool
/usr/bin/mysql to connect to the mysql
database and look at the grant tables:
shell> /usr/bin/mysql -u root mysql
mysql> show tables
Try 'mysqld --help' if you have problems with paths. Using --log
gives you a log in /var/lib/mysql that may be helpful.
The latest information about MySQL is available on the web at http://www.mysql.com
Please consult the MySQL manual section: 'Problems running mysql_install_db',
and the manual section that describes problems on your OS.
Another information source is the MySQL email archive.
Please check all of the above before mailing us!
And if you do mail us, you MUST use the /usr/bin/mysqlbug script!
chown: ne peut lire le r�pertoire `/var/lib/mysql': Permission non accord�e
chmod: modification des permissions de `/var/lib/mysql': Op�ration non permise
Starting MySQL: /etc/init.d/mysqld: line 165: kill: (17449) - Aucun processus de ce type
[�CHEC ]
Alors essayons de réflechir un peu...
passage de login ALL=(root) NOPASSWD:/etc/init.d/httpd, /etc/init.d/mysqld
en première ligne:il demande le mdp
passage de login ALL=(root) NOPASSWD:/etc/init.d/httpd, /etc/init.d/mysqld
en dernière ligne:il demande le mdp
mise en place de %STAFF ALL=(root) NOPASSWD:/etc/init.d/httpd, /etc/init.d/mysqld
idem...
Bah pour mon niveau de débutant qui n'est pas celui d'un "consultant / formateur en solutions et support open source": OUI
En tout les cas actuellement, j'ai un bouton qui execute "sudo allumageapache.sh" qui ouvre un terminal qui me demande mon mot de passe.
Mais pour faire cela je peut ouvir un console, me logguer en root et lancer les deux services. ca change pas grand chose.
Ca dois pas être: "C'est *si* difficile " mais actuellement j'y suis pas...
de base si je faisais sudo il me disais: sacha is not in the sudoers file. This incident will be reported.
je me suis donc rajouter dans visudo:
# sudoers file.
[...]
# User alias specification
User_Alias STAFF=sacha
[...]
#test
login ALL=(root) NOPASSWD:/etc/init.d/httpd, /etc/init.d/mysqld
[...]
# User privilege specification
root ALL=(ALL) ALL
STAFF ALL=(ALL) ALL
Et effectivement si je fais sudo allumageapache.sh il me demande mon mot de passe et c'est bon.
d'ailleurs je peut même commenter la ligne login ALL=(root) NOPASSWD:/etc/init.d/httpd, /etc/init.d/mysql
et ca fonctionne toujours...
Hors le but à l'origine etait de pouvoir lancer le serveur par un click, ou raccourci clavier.?
Alors voici mon ficher "visudo"
# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
# Failure to use 'visudo' may result in syntax or file permission errors
# that prevent sudo from running.
#
# See the sudoers man page for the details on how to write a sudoers file.
#
j'essaye donc de lancer allumageapache.sh
et là: [sacha@localhost ~]$ allumageapache.sh
/bin/allumageapache.sh: line 2: /etc/init.d/httpd: Permission non accordée
/bin/allumageapache.sh: line 3: /etc/init.d/mysqld: Permission non accordée
je reverifie les droits sous /etc/init.d -rwx------ 1 root root 9441 2008-03-08 01:22 httpd*
-rwx------ 1 root root 12219 2009-07-27 00:29 mysqld*
je remet les droits en 777 [root@localhost /etc/init.d]# chmod 777 httpd
[root@localhost /etc/init.d]# chmod 777 mysqld
Je sors du compte root, relance allumageapach.sh:
[sacha@localhost /etc/init.d]$ allumageapache.sh
Starting httpd: (13)Permission denied: make_sock: could not bind to address 127.0.0.1:80
no listening sockets available, shutting down
Unable to open logs
[�CHEC ]
ls: ne peut ouvrir le r�pertoire /var/lib/mysql/mysql: Permission non accord�e
Initializing MySQL database:
Installing MySQL system tables...
091127 15:49:18 [Warning] Can't create test file /var/lib/mysql/localhost.lower-test
091127 15:49:18 [Warning] Can't create test file /var/lib/mysql/localhost.lower-test
091127 15:49:18 [Warning] One can only use the --user switch if running as root
ERROR: 1347 'mysql.db' is not BASE TABLE
091127 15:49:18 [ERROR] Aborting
Examine the logs in /var/lib/mysql for more information.
You can try to start the mysqld daemon with:
/usr/sbin/mysqld --skip-grant &
and use the command line tool
/usr/bin/mysql to connect to the mysql
database and look at the grant tables:
shell> /usr/bin/mysql -u root mysql
mysql> show tables
Try 'mysqld --help' if you have problems with paths. Using --log
gives you a log in /var/lib/mysql that may be helpful.
The latest information about MySQL is available on the web at http://www.mysql.com
Please consult the MySQL manual section: 'Problems running mysql_install_db',
and the manual section that describes problems on your OS.
Another information source is the MySQL email archive.
Please check all of the above before mailing us!
And if you do mail us, you MUST use the /usr/bin/mysqlbug script!
chown: ne peut lire le r�pertoire `/var/lib/mysql': Permission non accord�e
chmod: modification des permissions de `/var/lib/mysql': Op�ration non permise
Starting MySQL: /etc/init.d/mysqld: line 165: kill: (5886) - Aucun processus de ce type
[�CHEC ]
Et bah je pensais que ca serais simple mais non...
voiçi mon ficher quand je tappe visudo (/etc/sudoers):
# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
# Failure to use 'visudo' may result in syntax or file permission errors
# that prevent sudo from running.
#
# See the sudoers man page for the details on how to write a sudoers file.
#
il me dis:
[sacha@localhost ~]$ allumageapache.sh
/bin/allumageapache.sh: line 2: /etc/init.d/httpd: Permission non accordée
/bin/allumageapache.sh: line 3: /etc/init.d/mysqld: Permission non accordée
Je retourne donc voir dans /etc/init.d les droits des fichiers, et la je vois:
-rwx------ 1 root root 9441 2008-03-08 01:22 httpd*
-rwx------ 1 root root 12219 2009-07-27 00:29 mysqld*
les fichiers ne sont plus en 777
je les repasse donc en 777
[root@localhost /etc/init.d]# chmod 777 httpd
[root@localhost /etc/init.d]# chmod 777 mysqld
je sors du compte root, relance allumageapache.sh et la:
[sacha@localhost /etc/init.d]$ allumageapache.sh
Starting httpd: (13)Permission denied: make_sock: could not bind to address 127.0.0.1:80
no listening sockets available, shutting down
Unable to open logs
[�CHEC ]
ls: ne peut ouvrir le r�pertoire /var/lib/mysql/mysql: Permission non accord�e
Initializing MySQL database:
Installing MySQL system tables...
091127 15:55:12 [Warning] Can't create test file /var/lib/mysql/localhost.lower-test
091127 15:55:12 [Warning] Can't create test file /var/lib/mysql/localhost.lower-test
091127 15:55:12 [Warning] One can only use the --user switch if running as root
ERROR: 1347 'mysql.db' is not BASE TABLE
091127 15:55:12 [ERROR] Aborting
Examine the logs in /var/lib/mysql for more information.
You can try to start the mysqld daemon with:
/usr/sbin/mysqld --skip-grant &
and use the command line tool
/usr/bin/mysql to connect to the mysql
database and look at the grant tables:
shell> /usr/bin/mysql -u root mysql
mysql> show tables
Try 'mysqld --help' if you have problems with paths. Using --log
gives you a log in /var/lib/mysql that may be helpful.
The latest information about MySQL is available on the web at http://www.mysql.com
Please consult the MySQL manual section: 'Problems running mysql_install_db',
and the manual section that describes problems on your OS.
Another information source is the MySQL email archive.
Please check all of the above before mailing us!
And if you do mail us, you MUST use the /usr/bin/mysqlbug script!
chown: ne peut lire le r�pertoire `/var/lib/mysql': Permission non accord�e
chmod: modification des permissions de `/var/lib/mysql': Op�ration non permise
Starting MySQL: /etc/init.d/mysqld: line 165: kill: (6816) - Aucun processus de ce type
[�CHEC ]
Bon du coup je pensais que ca serais un truc tout simple, mais en faite ... non
[^] # Merci
Posté par gotcha5832 . En réponse au message script + konqueror. Évalué à 1.
C'est celà
#!/bin/bash
# Nom du nouveau répertoire
NV_DOSSIER=reduc
echo 'dossier'
echo $1
cd "$1"
# Création du nouveau dossier s'il n'existe pas
if [ -d $NV_DOSSIER ] ;
then
echo "Le dossier reduc existe déjà"
else
mkdir $NV_DOSSIER
fi
rep=$(pwd)
jourmois=$(date +'%d%m')
rep="${rep##*/}"
rep="${rep// /-}"
# Pour toutes les photos (JPG) du répertoire
for image in *[jJ][pP][gG] ;
do
width=$(identify -format '%w' "$image")
height=$(identify -format '%h' "$image")
ratio=$(echo "scale=2; $height / $width" |bc)
echo $ratio
if [ $ratio '<' .70 ]
then
image="${image##*/}"
nv_nom=$(printf '%s_%s_%s\n' ${rep} ${jourmois} $image) #on dit merci à Fred
# Réduit l'image en 601x400
convert "$image" -resize 601x400 "$NV_DOSSIER/$nv_nom"
# fusione l'image avec un calque contenant les coins
composite -gravity center /home/sacha/Images/cadre.png "$NV_DOSSIER/$nv_nom" "$NV_DOSSIER/$nv_nom"
# fin de la boucle FOR
else
nv_nom=$(printf 'thai_prod_%s_%s.jpg\n' ${rep} ${jourmois}) #on dit merci à Fred
# Réduit l'image en 601x400
convert "$image" -resize 200x150 "$NV_DOSSIER/$nv_nom"
# fusione l'image avec un calque contenant les coins
composite -gravity center /home/sacha/Images/cadremini.png "$NV_DOSSIER/$nv_nom" "$NV_DOSSIER/$nv_nom"
fi
done
echo '-Fini !!!'
exit
Mille merci
[^] # Re: Une idée en passant.
Posté par gotcha5832 . En réponse au message Lecteur CD/DVD lit plus que CD. Évalué à 1.
"tail -f /var/log/messages" ne donne rien.
Mais j'ai essayé de booter sur deux CDboot que j'ai et j'ai des erreurs à chaque fois.
et si j'essaye de booter sur un dvd il le lit même pas...
Je pense donc que c'est hardware..?
Merci à vous
[^] # Re: passage paramètre ?
Posté par gotcha5832 . En réponse au message script + konqueror. Évalué à 1.
mon code:
Exec=reduc.sh "%f"
et
echo 'origin'
echo $1
rep_courant="${1// /\ }"
echo 'rep_courant'
echo $rep_courant
echo 'cd1'
cd $rep_courant
echo 'cd2'
cd '$rep_courant'
echo 'cd3'
cd "$rep_courant"
echo 'cd4'
cd $($rep_courant)
Resultat:
origin
/home/sacha/test image
rep_courant
/home/sacha/test\ image
cd1
/bin/reduc.sh: line 11: cd: /home/sacha/test\: Aucun fichier ou répertoire de ce type
cd2
/bin/reduc.sh: line 13: cd: $rep_courant: Aucun fichier ou répertoire de ce type
cd3
/bin/reduc.sh: line 15: cd: /home/sacha/test\ image: Aucun fichier ou répertoire de ce type
cd4
/bin/reduc.sh: line 17: /home/sacha/test\: Aucun fichier ou répertoire de ce type
Le dossier reduc existe déjà
[^] # Re: passage paramètre ?
Posté par gotcha5832 . En réponse au message script + konqueror. Évalué à 1.
juste %f à la place de %d, qui parait mon adapter à mon.
Mais petit dernier soucis
si je met
Exec=reduc.sh %f
puis dans reduc.sh
rep=$1
echo rep
cd $rep
ca me donne dans le ou ~/test dossier/
~/test dossier
/bin/reduc.sh: line 10: /home/sacha/test\: Aucun fichier ou répertoire de ce type
il me coupe le nom du dossier à l'espace
j'ai aussi essayer:
echo $1
rep_courant="${1// /\ }"
echo 'rep_courant'
echo $rep_courant
cd $($rep_courant)
cd "$rep_courant"
mais idem
[^] # servicemenu sous kde 3.5
Posté par gotcha5832 . En réponse au message renommer les fichier par script en nom_dossier_jour.jpg. Évalué à 1.
/usr/share/apps/konqueror/servicemenus/
j'ai crée un service menu du type:
[Desktop Entry]
ServiceTypes=inode/directory
Actions=reduc_imagecata;
[Desktop Action reduc_imagecata]
Name=reduc
Name[fr]=reduc
Icon=ark
Exec=reduc.sh
Il apparait bien sous konqueror, mais il ne s'execute pas.
J'ai donc tester en lancant konqueror via la console, pour voir les eventuelle message d'erreur et là ca fonctionne.
Vous auriez une idée pourquoi mon script ne fonctionne qu'a partir konqueror lancer via une console?
Merci à vous
[^] # FINI!!!!
Posté par gotcha5832 . En réponse au message renommer les fichier par script en nom_dossier_jour.jpg. Évalué à 2.
# Nom du nouveau répertoire
NV_DOSSIER=reduc
# Création du nouveau dossier s'il n'existe pas
if [ -d $NV_DOSSIER ] ;
then
echo "Le dossier reduc existe déjà"
else
mkdir $NV_DOSSIER
fi
rep=$(pwd)
jourmois=$(date +'%d%m')
# Pour toutes les photos (JPG) du répertoire
for image in *[jJ][pP][gG] ;
do
rep="${rep##*/}"
rep="${rep// /-}"
width=$(identify -format '%w' "$image")
height=$(identify -format '%h' "$image")
ratio=$(echo "scale=2; $height / $width" |bc)
echo $ratio
if [ $ratio '<' .70 ]
then
image="${image##*/}"
nv_nom=$(printf '%s_%s_%s\n' ${rep} ${jourmois} $image) #on dit merci à Fred
# Réduit l'image en 601x400
convert "$image" -resize 601x400 "$NV_DOSSIER/$nv_nom"
# fusione l'image avec un calque contenant les coins
composite -gravity center /home/sacha/Bureau/cadre.png "$NV_DOSSIER/$nv_nom" "$NV_DOSSIER/$nv_nom"
# fin de la boucle FOR
else
nv_nom=$(printf 'thai_prod_%s_%s.jpg\n' ${rep} ${jourmois}) #on dit merci à Fred
# Réduit l'image en 601x400
convert "$image" -resize 200x150 "$NV_DOSSIER/$nv_nom"
# fusione l'image avec un calque contenant les coins
composite -gravity center /home/sacha/Bureau/cadremini.png "$NV_DOSSIER/$nv_nom" "$NV_DOSSIER/$nv_nom"
fi
done
[^] # Re: suite
Posté par gotcha5832 . En réponse au message renommer les fichier par script en nom_dossier_jour.jpg. Évalué à 1.
width=$(identify -format '%w' "$image")
height=$(identify -format '%h' "$image")
ratio=$(($width / $height))
echo $ratio
if [ $ratio -gt 0.7 ]
mais j'arrive pas à faire la division avec décimal. il me renvoie toujours $ratio
et pour le if il me dis:
/bin/reduc.sh: line 24: [: 0.7: integer expression expected
Merci à vous
[^] # Re: suite
Posté par gotcha5832 . En réponse au message renommer les fichier par script en nom_dossier_jour.jpg. Évalué à 1.
j'ai trouver la fonction identify
qui permet de récupérer l'information que l'on veux sur un fichier
j'ai donc fais:
identify -format '%w' $image $width
identify -format '%h' $image $height
ratio=$(($width / $height))
if [ratio...
mais à chaque fois il me renvoie bien le résultat des identify mais les variable width et height reste vite.
j'arrive pas à trouver la bonne syntaxe.
[^] # Re: suite
Posté par gotcha5832 . En réponse au message renommer les fichier par script en nom_dossier_jour.jpg. Évalué à 2.
# Nom du nouveau répertoire
NV_DOSSIER=reduc
# Création du nouveau dossier s'il n'existe pas
if [ -d $NV_DOSSIER ] ;
then
echo "Le dossier reduc existe déjà"
else
mkdir $NV_DOSSIER
fi
rep=$(pwd)
num=1
jourmois=$(date +'%d%m')
# Pour toutes les photos produit (JPG) du répertoire nommé 1.JPG,2.JPG....
for image in [123456789].[jJ][pP][gG] ;
do
((++num))
# rep="${image%/*}"
rep="${rep##*/}"
rep="${rep// /-}"
image="${image##*/}"
nv_nom=$(printf '%s_%s_%s\n' ${rep} ${jourmois} $image) #on dit merci à Fred
# Réduit l'image en 601x400
convert "$image" -resize 601x400 "$NV_DOSSIER/$nv_nom"
# fusione l'image avec un calque contenant les coins
composite -gravity center /home/sacha/Bureau/cadre.png "$NV_DOSSIER/$nv_nom" "$NV_DOSSIER/$nv_nom"
# fin de la boucle FOR
done
# Pour toutes les photos producteur (JPG) du répertoire nommé prod.JPG
rep=$(pwd)
image=''
nv_nom=''
for image in prod.[jJ][pP][gG] ;
do
((++num))
# rep="${image%/*}"
rep="${rep##*/}"
rep="${rep// /-}"
image="${image##*/}"
nv_nom=$(printf 'thai_prod_%s_%s.jpg\n' ${rep} ${jourmois}) #on dit merci à Fred
# Réduit l'image en 601x400
convert "$image" -resize 200x150 "$NV_DOSSIER/$nv_nom"
# fusione l'image avec un calque contenant les coins
composite -gravity center /home/sacha/Bureau/cadremini.png "$NV_DOSSIER/$nv_nom" "$NV_DOSSIER/$nv_nom"
# fin de la boucle FOR
done
J'ai réussit a faire les deux boucles en une.
cependant j'en ai rajouter une, car j'ai deux type d'image
1- produit 1.JPG, 2.JPG 2816x1880px
2-producteur prod.JPG 2272x1704px
et que la 1- est réduite en 601x400
et la 2 en 200x150
cependant au lieu de tester par le nom de l'image serait il possible de tester par le ration d'image?
MERCI ENCORE A VOUS TOUS
[^] # Re: suite
Posté par gotcha5832 . En réponse au message renommer les fichier par script en nom_dossier_jour.jpg. Évalué à 1.
Du coup j'ai pas de dossier /usr/share/kde
J'ai essayer de le mettre sous
~/.kde/share/services/
puis j'ai crée un dossier ServiceMenu mais ca semble pas fonctionner...
Merci encore
[^] # Re: suite
Posté par gotcha5832 . En réponse au message renommer les fichier par script en nom_dossier_jour.jpg. Évalué à 1.
D'autant plus que j'ai deux type d'image
produit/producteur
avec des tailles différentes, et des noms différents
Du coup, pour l'instant ca me fais 4 boucles... et c'est horriblement long.
Mais j'y travaille et je vous présente celà dès que j'ai fini.
Merci à vous.
[^] # Re: suite
Posté par gotcha5832 . En réponse au message renommer les fichier par script en nom_dossier_jour.jpg. Évalué à 1.
En clair que sous konqueror je fasse click droit sur le dossier, et qu'il me propose reduc
et qu'il applique ce script sur ce dossier?
Merci à vous
[^] # Re: suite
Posté par gotcha5832 . En réponse au message renommer les fichier par script en nom_dossier_jour.jpg. Évalué à 1.
Merci
# Nom du nouveau répertoire
NV_DOSSIER=reduc
# Création du nouveau dossier s'il n'existe pas
if [ -d $NV_DOSSIER ] ;
then
echo "Le dossier reduc existe déjà"
else
mkdir $NV_DOSSIER
fi
# Pour toutes les photos (JPG) du répertoire
for i in *.[jJ][pP][gG] ;
do
# Réduit l'image en 601x400
convert "$i" -resize 601x400 "$NV_DOSSIER/$i"
# fusione l'image avec un calque contenant les coins
composite -gravity center /home/sacha/Bureau/cadre.png "$NV_DOSSIER/$i" "$NV_DOSSIER/$i"
# fin de la boucle FOR
done
rep=$(pwd)
cd "$NV_DOSSIER"
# mise a zero (1) du compteur
num=1
jourmois=$(date +'%d%m')
for image in "$rep"/*[jJ][pP][gG]; do
((++num))
rep="${image%/*}"
rep="${rep##*/}"
rep="${rep// /_}"
image="${image##*/}"
nv_nom=$(printf '%s_%s_%.4d_%s\n' ${rep} ${jourmois} ${num} $image) #on dit merci à Fred
mv "$image" $nv_nom
done
# suite
Posté par gotcha5832 . En réponse au message renommer les fichier par script en nom_dossier_jour.jpg. Évalué à 1.
mais moi j'ai un créer un scriptnew.sh
cd "/home/sacha/Bureau/image test"
name=${basename "$(pwd)"}
name=${name// /_}
echo $name
et ca me donne:
[sacha@localhost ~/Bureau/image test]$ scriptnew.sh
/bin/scriptnew.sh: line 2: ${basename "$(pwd)"}: bad substitution
et si j'essaye
cd "/home/sacha/Bureau/image test"
name=$(basename $(pwd))
name=${name// /_}
echo $name
ca me donne:
[sacha@localhost ~/Bureau/image test]$ scriptnew.sh
image
avec:
name=basename "$(pwd)"
==> /bin/scriptnew.sh: line 2: /home/sacha/Bureau/image test: is a directory
name=basename $(pwd)
==>/bin/scriptnew.sh: line 2: /home/sacha/Bureau/image: Aucun fichier ou répertoire de ce type
du coup je suis un peu perdu?
[^] # Re: Oui, c'est possible
Posté par gotcha5832 . En réponse au message Créer un bouton qui lance Apache. Évalué à 1.
[quote]Dans l'absolu, si tu veux lancer un script monscript.sh en sudo sans mot de passe, il y a une solution simple :
Tu crées ton script que tu places quelque part, par exemple dans /home/moi/
Puis visudo
- dans la ligne # Cmnd alias specification tu mets :
[CODE]
# Cmnd alias specification
Cmnd_Alias SCRIPT = /home/moi/monscript.sh[/CODE]
- Tu ajoutes le groupe wheel à ton utilisateur (toi ..)
- et tu décommentes la ligne
[CODE]
# %wheel ALL=(ALL) NOPASSWD: ALL[/CODE]
devenant :
[CODE]
%wheel ALL=(ALL) NOPASSWD: ALL[/CODE]
Remarques que tu étais près du but. Sur ton visudo, il te suffirait de transformer la ligne
[CODE]
STAFF ALL=(ALL) ALL[/CODE]
en
[CODE]
STAFF ALL= (ALL) NOPASSWD: ALL[/CODE]
Comme ça, pas de passwd
YL
[/quote]
[^] # Re: Oui, c'est possible
Posté par gotcha5832 . En réponse au message Créer un bouton qui lance Apache. Évalué à 1.
On repart au début:
Visudo:
# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
# Failure to use 'visudo' may result in syntax or file permission errors
# that prevent sudo from running.
#
# See the sudoers man page for the details on how to write a sudoers file.
#
#login ALL=(root) NOPASSWD:/etc/init.d/httpd, /etc/init.d/mysqld
# Host alias specification
# User alias specification
User_Alias STAFF=sacha
# Cmnd alias specification
# Defaults specification
# Runas alias specification
#test
#login ALL=(root) NOPASSWD:/etc/init.d/httpd, /etc/init.d/mysqld
# User privilege specification
root ALL=(ALL) ALL
STAFF ALL=(ALL) ALL
# Uncomment to allow people in group wheel to run all commands
# %wheel ALL=(ALL) ALL
# Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL
#%STAFF ALL=(root) NOPASSWD:/etc/init.d/httpd, /etc/init.d/mysqld
# Samples
# %users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
# %users localhost=/sbin/shutdown -h now
login ALL=(root) NOPASSWD:/etc/init.d/httpd, /etc/init.d/mysqld
j'ai ensuite créer un fichier /bin/allumageapache.sh
dans lequel j'ai rajouter:
#!/bin/bash
/etc/init.d/httpd start
/etc/init.d/mysqld start
puis adapter les droits du script
enfin je lance la commande
sudo allumageapache.sh
et il me demande dans tout les cas le mot de passe sans message d'erreur.
P.S.: un trouve plusieurs fois la ligne
#login ALL=(root) NOPASSWD:/etc/init.d/httpd, /etc/init.d/mysqld
ce sont les différents endroit ou j'ai essayé.
j'ai aussi essayé:
%STAFF ALL=(root) NOPASSWD:/etc/init.d/httpd, /etc/init.d/mysqld
enfin si j'esssaye sans sudo:
[sacha@localhost ~]$ allumageapache.sh
Starting httpd: (13)Permission denied: make_sock: could not bind to address 127.0.0.1:80
no listening sockets available, shutting down
Unable to open logs
[�CHEC ]
ls: ne peut ouvrir le r�pertoire /var/lib/mysql/mysql: Permission non accord�e
Initializing MySQL database:
Installing MySQL system tables...
091202 19:20:22 [Warning] Can't create test file /var/lib/mysql/localhost.lower-test
091202 19:20:22 [Warning] Can't create test file /var/lib/mysql/localhost.lower-test
091202 19:20:22 [Warning] One can only use the --user switch if running as root
ERROR: 1347 'mysql.db' is not BASE TABLE
091202 19:20:22 [ERROR] Aborting
091202 19:20:22 [Note] /usr/sbin/mysqld: Shutdown complete
Installation of system tables failed!
Examine the logs in /var/lib/mysql for more information.
You can try to start the mysqld daemon with:
/usr/sbin/mysqld --skip-grant &
and use the command line tool
/usr/bin/mysql to connect to the mysql
database and look at the grant tables:
shell> /usr/bin/mysql -u root mysql
mysql> show tables
Try 'mysqld --help' if you have problems with paths. Using --log
gives you a log in /var/lib/mysql that may be helpful.
The latest information about MySQL is available on the web at
http://www.mysql.com
Please consult the MySQL manual section: 'Problems running mysql_install_db',
and the manual section that describes problems on your OS.
Another information source is the MySQL email archive.
Please check all of the above before mailing us!
And if you do mail us, you MUST use the /usr/bin/mysqlbug script!
chown: ne peut lire le r�pertoire `/var/lib/mysql': Permission non accord�e
chmod: modification des permissions de `/var/lib/mysql': Op�ration non permise
Starting MySQL: /etc/init.d/mysqld: line 165: kill: (17449) - Aucun processus de ce type
[�CHEC ]
[^] # Re: Oui, c'est possible
Posté par gotcha5832 . En réponse au message Créer un bouton qui lance Apache. Évalué à 1.
passage de
login ALL=(root) NOPASSWD:/etc/init.d/httpd, /etc/init.d/mysqld
en première ligne:il demande le mdp
passage de
login ALL=(root) NOPASSWD:/etc/init.d/httpd, /etc/init.d/mysqld
en dernière ligne:il demande le mdp
mise en place de
%STAFF ALL=(root) NOPASSWD:/etc/init.d/httpd, /etc/init.d/mysqld
idem...
[^] # Re: Oui, c'est possible
Posté par gotcha5832 . En réponse au message Créer un bouton qui lance Apache. Évalué à 1.
Car là a vrai dire tes commentaire ne me sont d'aucune utilité...
Dis moi tu as pas un travail, un hobby, une occupation qui pourrais t'occuper?
[^] # Re: Oui, c'est possible
Posté par gotcha5832 . En réponse au message Créer un bouton qui lance Apache. Évalué à 1.
Question à 3 centime pourquoi avec mon sudoers, il me le demande toujours?
[^] # Re: Oui, c'est possible
Posté par gotcha5832 . En réponse au message Créer un bouton qui lance Apache. Évalué à 1.
En tout les cas actuellement, j'ai un bouton qui execute "sudo allumageapache.sh" qui ouvre un terminal qui me demande mon mot de passe.
Mais pour faire cela je peut ouvir un console, me logguer en root et lancer les deux services. ca change pas grand chose.
Ca dois pas être: "C'est *si* difficile " mais actuellement j'y suis pas...
[^] # Re: Oui, c'est possible
Posté par gotcha5832 . En réponse au message Créer un bouton qui lance Apache. Évalué à 1.
sacha is not in the sudoers file. This incident will be reported.
je me suis donc rajouter dans visudo:
# sudoers file.
[...]
# User alias specification
User_Alias STAFF=sacha
[...]
#test
login ALL=(root) NOPASSWD:/etc/init.d/httpd, /etc/init.d/mysqld
[...]
# User privilege specification
root ALL=(ALL) ALL
STAFF ALL=(ALL) ALL
Et effectivement si je fais sudo allumageapache.sh il me demande mon mot de passe et c'est bon.
d'ailleurs je peut même commenter la ligne
login ALL=(root) NOPASSWD:/etc/init.d/httpd, /etc/init.d/mysql
et ca fonctionne toujours...
Hors le but à l'origine etait de pouvoir lancer le serveur par un click, ou raccourci clavier.?
[^] # Re: Oui, c'est possible
Posté par gotcha5832 . En réponse au message Créer un bouton qui lance Apache. Évalué à 1.
[^] # Re: sudo -l
Posté par gotcha5832 . En réponse au message Créer un bouton qui lance Apache. Évalué à 1.
j'ai essayé de faire un sudo -l mais:
[root@localhost /]# sudo -l
User root may run the following commands on this host:
(ALL) ALL
???
Je sais pas quoi faire?
[^] # Re: Oui, c'est possible
Posté par gotcha5832 . En réponse au message Créer un bouton qui lance Apache. Évalué à 1.
# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
# Failure to use 'visudo' may result in syntax or file permission errors
# that prevent sudo from running.
#
# See the sudoers man page for the details on how to write a sudoers file.
#
# Host alias specification
# User alias specification
# Cmnd alias specification
# Defaults specification
# Runas alias specification
#test
login ALL=(root) NOPASSWD:/etc/init.d/httpd, /etc/init.d/mysqld
# User privilege specification
root ALL=(ALL) ALL
# Uncomment to allow people in group wheel to run all commands
# %wheel ALL=(ALL) ALL
# Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL
# Samples
# %users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
# %users localhost=/sbin/shutdown -h now
j'essaye donc de lancer allumageapache.sh
et là:
[sacha@localhost ~]$ allumageapache.sh
/bin/allumageapache.sh: line 2: /etc/init.d/httpd: Permission non accordée
/bin/allumageapache.sh: line 3: /etc/init.d/mysqld: Permission non accordée
je reverifie les droits sous /etc/init.d
-rwx------ 1 root root 9441 2008-03-08 01:22 httpd*
-rwx------ 1 root root 12219 2009-07-27 00:29 mysqld*
je remet les droits en 777
[root@localhost /etc/init.d]# chmod 777 httpd
[root@localhost /etc/init.d]# chmod 777 mysqld
Je sors du compte root, relance allumageapach.sh:
[sacha@localhost /etc/init.d]$ allumageapache.sh
Starting httpd: (13)Permission denied: make_sock: could not bind to address 127.0.0.1:80
no listening sockets available, shutting down
Unable to open logs
[�CHEC ]
ls: ne peut ouvrir le r�pertoire /var/lib/mysql/mysql: Permission non accord�e
Initializing MySQL database:
Installing MySQL system tables...
091127 15:49:18 [Warning] Can't create test file /var/lib/mysql/localhost.lower-test
091127 15:49:18 [Warning] Can't create test file /var/lib/mysql/localhost.lower-test
091127 15:49:18 [Warning] One can only use the --user switch if running as root
ERROR: 1347 'mysql.db' is not BASE TABLE
091127 15:49:18 [ERROR] Aborting
091127 15:49:18 [Note] /usr/sbin/mysqld: Shutdown complete
Installation of system tables failed!
Examine the logs in /var/lib/mysql for more information.
You can try to start the mysqld daemon with:
/usr/sbin/mysqld --skip-grant &
and use the command line tool
/usr/bin/mysql to connect to the mysql
database and look at the grant tables:
shell> /usr/bin/mysql -u root mysql
mysql> show tables
Try 'mysqld --help' if you have problems with paths. Using --log
gives you a log in /var/lib/mysql that may be helpful.
The latest information about MySQL is available on the web at
http://www.mysql.com
Please consult the MySQL manual section: 'Problems running mysql_install_db',
and the manual section that describes problems on your OS.
Another information source is the MySQL email archive.
Please check all of the above before mailing us!
And if you do mail us, you MUST use the /usr/bin/mysqlbug script!
chown: ne peut lire le r�pertoire `/var/lib/mysql': Permission non accord�e
chmod: modification des permissions de `/var/lib/mysql': Op�ration non permise
Starting MySQL: /etc/init.d/mysqld: line 165: kill: (5886) - Aucun processus de ce type
[�CHEC ]
Et bah je pensais que ca serais simple mais non...
[^] # Re: Oui, c'est possible
Posté par gotcha5832 . En réponse au message Créer un bouton qui lance Apache. Évalué à 1.
voiçi mon ficher quand je tappe visudo (/etc/sudoers):
# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
# Failure to use 'visudo' may result in syntax or file permission errors
# that prevent sudo from running.
#
# See the sudoers man page for the details on how to write a sudoers file.
#
# Host alias specification
# User alias specification
# Cmnd alias specification
# Defaults specification
# Runas alias specification
#test
login ALL=(root) NOPASSWD:/etc/init.d/httpd, /etc/init.d/mysqld
# User privilege specification
root ALL=(ALL) ALL
# Uncomment to allow people in group wheel to run all commands
# %wheel ALL=(ALL) ALL
# Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL
# Samples
# %users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
# %users localhost=/sbin/shutdown -h now
il me dis:
[sacha@localhost ~]$ allumageapache.sh
/bin/allumageapache.sh: line 2: /etc/init.d/httpd: Permission non accordée
/bin/allumageapache.sh: line 3: /etc/init.d/mysqld: Permission non accordée
Je retourne donc voir dans /etc/init.d les droits des fichiers, et la je vois:
-rwx------ 1 root root 9441 2008-03-08 01:22 httpd*
-rwx------ 1 root root 12219 2009-07-27 00:29 mysqld*
les fichiers ne sont plus en 777
je les repasse donc en 777
[root@localhost /etc/init.d]# chmod 777 httpd
[root@localhost /etc/init.d]# chmod 777 mysqld
je sors du compte root, relance allumageapache.sh et la:
[sacha@localhost /etc/init.d]$ allumageapache.sh
Starting httpd: (13)Permission denied: make_sock: could not bind to address 127.0.0.1:80
no listening sockets available, shutting down
Unable to open logs
[�CHEC ]
ls: ne peut ouvrir le r�pertoire /var/lib/mysql/mysql: Permission non accord�e
Initializing MySQL database:
Installing MySQL system tables...
091127 15:55:12 [Warning] Can't create test file /var/lib/mysql/localhost.lower-test
091127 15:55:12 [Warning] Can't create test file /var/lib/mysql/localhost.lower-test
091127 15:55:12 [Warning] One can only use the --user switch if running as root
ERROR: 1347 'mysql.db' is not BASE TABLE
091127 15:55:12 [ERROR] Aborting
091127 15:55:12 [Note] /usr/sbin/mysqld: Shutdown complete
Installation of system tables failed!
Examine the logs in /var/lib/mysql for more information.
You can try to start the mysqld daemon with:
/usr/sbin/mysqld --skip-grant &
and use the command line tool
/usr/bin/mysql to connect to the mysql
database and look at the grant tables:
shell> /usr/bin/mysql -u root mysql
mysql> show tables
Try 'mysqld --help' if you have problems with paths. Using --log
gives you a log in /var/lib/mysql that may be helpful.
The latest information about MySQL is available on the web at
http://www.mysql.com
Please consult the MySQL manual section: 'Problems running mysql_install_db',
and the manual section that describes problems on your OS.
Another information source is the MySQL email archive.
Please check all of the above before mailing us!
And if you do mail us, you MUST use the /usr/bin/mysqlbug script!
chown: ne peut lire le r�pertoire `/var/lib/mysql': Permission non accord�e
chmod: modification des permissions de `/var/lib/mysql': Op�ration non permise
Starting MySQL: /etc/init.d/mysqld: line 165: kill: (6816) - Aucun processus de ce type
[�CHEC ]
Bon du coup je pensais que ca serais un truc tout simple, mais en faite ... non