Results 1 to 6 of 6
Hello everyone, I am having trouble executing a script
When I try to, I get this:
Line 31: Syntax error near unexpected token fi
Line 31: fi
Code:
if test ...
- 02-27-2009 #1Just Joined!
- Join Date
- Feb 2009
- Posts
- 3
[SOLVED] Syntax error near unexpected token fi
Hello everyone, I am having trouble executing a script
When I try to, I get this:
Line 31: Syntax error near unexpected token fi
Line 31: fi
Code:if test $# = 0 then echo echo This script requires 1 argument exit fi declare -i fileCount declare -i dirCount declare -i exeCount fileCount=0 dirCount=0 exeCount=0 for i in $* do if test -f $1 then fileCount=fileCount+1 fi if test -d $1 then dirCount=dirCount+1 fi if test -x $1 then exeCount=exeCount+1 fi done fi echo Number of Files found=$fileCount echo Number of Directories found=$dirCount echo Number of Executable Files found=$exeCount
- 02-27-2009 #2Just Joined!
- Join Date
- Feb 2009
- Posts
- 13
hi Dan,
i am not an expert but guess if you remove the very last 'fi' (after done) guess the script will work.
- 02-27-2009 #3Just Joined!
- Join Date
- Feb 2009
- Posts
- 3
Ok, I did it and I still got the error message
Code:if test $# = 0 then echo echo This script requires 1 argument exit fi declare -i fileCount declare -i dirCount declare -i exeCount fileCount=0 dirCount=0 exeCount=0 for i in $* do if test -f $1 then fileCount=fileCount+1 fi if test -d $1 then dirCount=dirCount+1 fi if test -x $1 then exeCount=exeCount+1 fi done echo Number of Files found=$fileCount echo Number of Directories found=$dirCount echo Number of Executable Files found=$exeCount
- 02-27-2009 #4Just Joined!
- Join Date
- Feb 2009
- Posts
- 13
i copied, pasted and ran your script and it ran without any error(s) for me.
- 02-27-2009 #5
Which distro are you using? Add #!/bin/bash as first line in the script.
Code:#!/bin/bash if test $# = 0 then echo echo This script requires 1 argument exit fi declare -i fileCount declare -i dirCount declare -i exeCount ---- ----
It is amazing what you can accomplish if you do not care who gets the credit.
New Users: Read This First
- 02-27-2009 #6Just Joined!
- Join Date
- Feb 2009
- Posts
- 3
Thanks for your help. I was editing the backup file instead of the original one which still had the extra 'fi'. It works fine now.



