Porting ksh script from Solaris to Linux Gives unmatched if error
Following is my script,which works perfectly fine on Solaris ksh, but when trying to run on RHEL 4 ksh, it gives the following error
upgrade.sh[4]: syntax error: `if' unmatched Is there anything special I need to do run on Linux. I need your help badly, dont know what match if is missing ### # DATABASE SCRIPTS ### 1. cd $upgradeDir 2. for dir in * 3. do 4. if [[ -d ${dir} ]] && ((${developmentUpgrade} && (( ${dir} >= ${currentRelease} ))) || (( ${dir} > ${currentRelease} ))) then #echo "DIR: $dir" cd ${dir} for file in *.dll do if [[ -f ${file} ]]; then executeCommand "${sqlCommand} @${file}" fi done cd .. fi done |
Please post scripts and other source code in [code] tags. This vastly improves readability by displaying with a fixed width font and preserving whitespace.
The 1. 2. 3. 4. beginnings to the lines are for what purpose? Are these supposed to be comments? If so you should start the line with a #, else you will get messages like this: Code:
1.: not found [No such file or directory] |
My apologies, I have modified the script below, so that it can run on your machine. It still giving me this error.
Line 9 : Syntax error near unexpected token 'fi'. Let me try as you suggested. Code:
developmentUpgrade=false |
I said that your if statement is incorrect. It is still incorrect. You cannot use normal brackets () - that is not valid shall syntax.
|
The script runs on Linux now
Thanks matthew :), The script works great, I had to play around and replace some (( with [[ ones. Here is the modifed code
Code:
developmentUpgrade=false |
All times are GMT -5. The time now is 09:09 PM. |