Hi, I am trying to make a script to manage log. I want to write the name of the .gz I moved and the date :
for i in `ls $replog/*.gz`
do
echo " $i "
`echo $i date +%d:%m:%Y`
`echo $datee `>> $replog/mrnet.log
mv $i /var/log/vieux-logs
done
I need to echo the date in /$replog/mrnet.log, but when I want to echo $i I have a error message : "Permision denied"
I tryed to echo everything once at once, and its really the $i the matter
I did chmod 700 on mrnet.log, I still have the issues. My Linux is in french, and I don't know how to trap the code tags I can take you a screen shot if you want
Ok, I can send you the full code, the error you mentioned was function I din't need, I deleted it. I will send you a new screen shot with the error message. The comment are in french, and the echo that end with #trace is for debug
#! /bin/bash
replog=/var/log
# V�rification du nombre d'entr�
if [ $# -eq 0 ] ; then
echo "Bon nombres de param�tre entr� !" #A retir�
# V�rification si il y a bien des .gz
ls -1 $replog/*.gz > /dev/null 2>&1
if [ "$?" = "0" ]; then
echo ".gz touvr� !!" # Trace
#Cr�ation du rep vieux-logs si besoin
if [ ! -d $replog/vieux-logs ] ; then
echo "vieux log n'existe pas ! cr�on le !" #trace
mkdir $replog/vieux-logs
else
echo "Vieux log existe ! Une �tape de moin !" #trace
fi
#V�rification si mrnet.log existe
if [ ! -f $replog/mrnet.log ] ; then
echo "Mrnet.log N'existe pas ! Cr�on le!" #trace
echo "Il ne faut pas oublier la fonction conteur !!!!" #trace
touch mrnet.log
else
echo "Tout est baux, une �tape de moins ! pas de mrnet.log a cr��" #trace
fi
#Boucle For
for i in $replog/*.gz
do
echo "Bravo, t'as comprit comment sa marche !" #trace
echo " $i "
`echo $i date +%d:%m:%Y` #this shit is fucked need help
`echo $datee `>> $replog/mrnet.log
mv $i /var/log/vieux-logs
done
# Compar� 5k
if [ `stat -c%s $replog/mrnet.log` -gt 5000 ]; then
echo "pipi caca pouet"
else
echo "cacapipipouet"
fi
else
echo "Pas de .gz trouv� :(" # TRace
fi
else
echo "Erreur Mauvais nombre de param�tre entr�" #trace
fi
---------- Post updated at 02:56 PM ---------- Previous update was at 02:56 PM ----------
You're my hero, it worked. So the matter was the `` needed to replace by "" and no echo in. Thanks ! If you have some time, I asked a question on the MV command on the same section of the forum!