lundi 2 février 2015

Hostname variable doesn't work


I'm on a Raspberry Pi using RPiTC (Raspberry Pi Thin Client).


I had made a script with an Hostname variable. It's worked perfectly but today when I had launch my script I saw something strange.


My Hostname variable doesn't work. I'm sure it's from my script, I had reload an image of my OS and it's the same. And when I take my old script (It's exactly the same script) it's worked.


So this is my script:



do_start()
#Creating and checking my Hostname variable
ThisHost=$(hostname)
date=$(date)
echo "This is my hostname check:"
echo $ThisHost

#This will find the file in the /home/rpitc folder and save it to a variable:
dest=$(find /home/rpitc/ -name "$ThisHost.ica")
echo "This is my dest check:"
echo $dest
findfile="${dest##*/}"
echo "This is my findfile check with extension:"
echo $findfile
echo "This is my findfile check WITHOUT extension:"
echo "${findfile%.*}"

#If check to see if my hostname $ThisHost matches the file $findfile:
if test "$ThisHost" = "${findfile%.*}"

then
echo "Worked!"
echo $ThisHost "is correct. Connected the" $date >> /home/rpitc/skelog
exit 0
else
ThisHost=$(hostname)
tftp 10.1.0.203 << fin
get /test/${ThisHost}.ica
quit
fin
if [ -s ${ThisHost}.ica ]
then
exec iceweasel /home/rpitc/${ThisHost}.ica
else
zenity --error --text="Your hostname is incorrect."
rm /home/rpitc/${ThisHost}.ica
fi
fi


I had transfer my script via tftp, maybe it's the problem? In the past I had transfer the same script with the tftp protocol and it's worked...



Aucun commentaire:

Enregistrer un commentaire