syntax error: unexpected end of file?

February 18, 2011 at 16:44:41
Specs: Linux x86_64
I keep getting this error with a script i wroteline 43: syntax error: unexpected end of file

the script is

#!/bin/bash
input=$(zenity --question --text "Would you like to update?")
retval=$?
yaourt=$(/usr/bin/yaourt)
pacman=$(/usr/bin/pacman)
ifyaourt()
if [ -d $yaourt]; then
hasyaourt=1;
usepacman=0;
neither=1;

else if [ -d $pacman]; then
hasyaourt=0;
usepacman=1;
neither=1;

else
neither=1;
fi


useyaourt()

if ["$hasyaourt"="1"]; then
yaourt -Syu --noconfirm

else if ["$usepacman"="1"]; then
pacman-Syu --noconfirm;
else if ["$neither"="1"]; then
zenity --info --text "Sorry this script doesent work on your os/or config";
fi
case $retval in
0)
ifyaourt;
useyaourt
;;
1)
zenity --text "Cancel pressed." --info
;;
esac


See More: syntax error: unexpected end of file?

Report •

#1
February 18, 2011 at 16:46:54
Try using elif instead of else if.

How To Ask Questions The Smart Way


Report •

#2
February 18, 2011 at 16:52:42
That kicks out

/home/tehrainbowguy/Scripts/update: line 7: [: missing `]'
/home/tehrainbowguy/Scripts/update: line 12: [: missing `]'
/home/tehrainbowguy/Scripts/update: line 24: [=1]: command not found
/home/tehrainbowguy/Scripts/update: line 27: [=1]: command not found
/home/tehrainbowguy/Scripts/update: line 29: [1=1]: command not found


Report •

#3
February 18, 2011 at 17:33:25
Razor is right about the use of elif, but I think you also have a problem with your definition of these objects:

yaourt=$(/usr/bin/yaourt)
pacman=$(/usr/bin/pacman)

You are using command subsitution, $(), which means the shell thinks /usr/bin/yaout and ../../pacman are valid commands. But since you are doing directory checks on these objects, don't you really mean to define them as strings?

# quotes are probably optional
yaourt="/usr/bin/yaourt"
pacman="/usr/bin/pacman"


Report •

Related Solutions

#4
February 18, 2011 at 19:26:49
Of cource!
Thats what I get for writing scripts in the middle of the night :P
Thank you so much :D

Report •

Ask Question