LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-27-2008, 02:53 PM   #1
markatharvestinfotec
LQ Newbie
 
Registered: Aug 2008
Posts: 5

Rep: Reputation: 0
Post 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

Last edited by markatharvestinfotec; 08-27-2008 at 02:54 PM.
 
Old 08-27-2008, 03:22 PM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 67
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]
The syntax of the if statement on the line starting with "4." is all wrong (never mind the fact that the 4. will make the if statement useless). You seem to have many "(( ... ))" when you should have "[[ ... ]]". That it runs on Solaris is a surprise - as far as I can tell this is not valid syntax.
 
Old 08-28-2008, 10:48 AM   #3
markatharvestinfotec
LQ Newbie
 
Registered: Aug 2008
Posts: 5

Original Poster
Rep: Reputation: 0
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
currentRelease=100
majorSeparator="=============================================================="
for dir in *
do
   if [[ -d ${dir} ]] && (  (${developmentUpgrade} && (( ${dir} >= ${currentRelease} ))) || (( ${dir} > ${currentRelease} )))
        #echo "DIR: $dir"
        echo "HELLO WORLD, I AM IN WORKING CONDITIONS"
    fi
done

Last edited by markatharvestinfotec; 08-28-2008 at 11:14 AM.
 
Old 08-28-2008, 11:52 AM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 67
I said that your if statement is incorrect. It is still incorrect. You cannot use normal brackets () - that is not valid shall syntax.
 
Old 08-28-2008, 01:51 PM   #5
markatharvestinfotec
LQ Newbie
 
Registered: Aug 2008
Posts: 5

Original Poster
Rep: Reputation: 0
Thumbs up 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
currentRelease=500
majorSeparator="=============================================================="
for dir in *
do
if [[ -d ${dir} ]] && ( (${developmentUpgrade} && (( ${dir} >= ${currentRelease} ))) || [[ ${dir} > ${currentRelease} ]] ) ; then
            echo "DIR: $dir"
        fi
done

Last edited by markatharvestinfotec; 08-28-2008 at 01:53 PM.
 
  


Reply

Tags
code


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Solaris to Linux Porting - dbutils error jerald Red Hat 0 10-30-2007 01:28 AM
Porting from Solaris to Linux gan_04 Linux - General 2 07-15-2005 08:37 AM
porting linux date script to Solaris svar Linux - Software 5 05-29-2004 04:54 AM
Porting from Solaris to Linux raees Linux - General 3 11-10-2003 09:26 AM
Porting from Solaris 2.6 to Linux rajneesh_134 Solaris / OpenSolaris 1 10-22-2003 09:20 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration