PDA

View Full Version : bash


texerasmo
16-03-2006, 09:52
Volevo fare questo script

#!/bin/sh
#
File="/home/mino/ControlloUtenti/statoutenti.txt"
#controllo gli utenti collegati
who > $File
#mi restiuisce il numero di righe
NumeroUtenti ='cat $File | wc -l'
echo "--> " $NumeroUtenti
utentiamm="2"
if ["$utentiamm" -eg "$NumeroUenti" ];then
echo 'utenti collegati 2 mandare un mail'
fi

exit 0

quando lo lancio mi da questo
-->
./controlloutenti.sh: line 10: [2: command not found


dove sbaglio...

kingv
16-03-2006, 11:00
Occhio agli spazi.

#!/bin/sh
#
File="/tmp/statoutenti.txt"
#controllo gli utenti collegati
who > $File
#mi restiuisce il numero di righe
NumeroUtenti=$(cat $File | wc -l)
echo "--> " $NumeroUtenti
utentiamm="2"
if [ "$utentiamm" == "$NumeroUtenti" ];then
echo 'utenti collegati 2 mandare un mail'
fi

exit 0


bash è una merd@ come sintassi.

texerasmo
16-03-2006, 12:02
grazie funziona