My script work on Linux but not work in sunos. | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

My script work on Linux but not work in sunos.

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-30-2013
ooilinlove's Avatar
ooilinlove ooilinlove is offline
Registered User
 
Join Date: Aug 2008
Last Activity: 17 April 2014, 8:42 AM EDT
Posts: 72
Thanks: 7
Thanked 0 Times in 0 Posts
My script work on Linux but not work in sunos.

My script work on Linux but not work in sun os.

my script.


Code:
logFiles="sentLog1.log sentLog2.log"
intial_time="0 0"
logLocation="/usr/local/tomcat/logs/"
sleepTime=600


failMessage=":: $(tput bold)Log not update$(tput rmso) = "
successMessage="OK"

arr=($logFiles)
time_arr=($intial_time)
arrlen=${#arr[@]}
arrcount=()



date
for count=0; count<arrlen; count++ ; do
    arrcount[$count]=`ls -l  $logLocation${arr[$count]}  |awk '{print $5}'`
    echo "${arr[$count]} Original size :: ${arrcount[$count]}"
done
echo

while [ "e" == "e" ] ; do 
    sleep $sleepTime
    date

    for ((count=0; count<arrlen; count++)) ; do
        nc=`ls -l  $logLocation${arr[$count]}  |awk '{print $5}'`
        echo -n "${arr[$count]} "
        if [ $nc == ${arrcount[$count]} ] ; then
         time_arr[$count]=`echo ${time_arr[$count]} + 10 | bc`       
            echo $failMessage " " ${time_arr[$count]} " Minute."
        else
            arrcount[$count]=$nc
            echo $successMessage
   time_arr[$count]=0
        fi
    done
    echo
 echo
 echo
 echo
done

run on linux it ok. but run on sun os it not ok.


output of sun os.

Code:
Wed Jan 30 17:08:28 USA 2013
./MonSellVASMDB.sh: line 18: syntax error near unexpected token `(('
./MonSellVASMDB.sh: line 18: `for ((count=0; count<arrlen; count++)) ; do'

Sponsored Links
    #2  
Old 01-30-2013
panyam panyam is offline Forum Advisor  
Registered User
 
Join Date: Sep 2008
Last Activity: 24 July 2014, 3:48 AM EDT
Posts: 1,156
Thanks: 20
Thanked 104 Times in 99 Posts
Which Shell are you using in Linux and in Unix?

It depends on the shell.
Sponsored Links
    #3  
Old 01-30-2013
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
 
Join Date: Dec 2003
Last Activity: 13 May 2013, 9:02 AM EDT
Location: Melbourne, Australia
Posts: 2,185
Thanks: 3
Thanked 24 Times in 23 Posts
Add a shebang to the top

Code:
#!/bin/bash

and it should work under (most recent) versions of Solaris.

You haven't specified an interpreter, so it'll default to using /bin/sh - fine for Linux ( /bin/sh is usually a symlink to /bin/bash ) but not SunOS where /bin/sh is the Bourne shell or Korn Shell depending on version (Solaris 11 has a symlink to ksh93 ).
    #4  
Old 01-30-2013
ooilinlove's Avatar
ooilinlove ooilinlove is offline
Registered User
 
Join Date: Aug 2008
Last Activity: 17 April 2014, 8:42 AM EDT
Posts: 72
Thanks: 7
Thanked 0 Times in 0 Posts
sun = /bin/ksh
linux = /bin/ksh
Sponsored Links
    #5  
Old 01-30-2013
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
 
Join Date: Dec 2003
Last Activity: 13 May 2013, 9:02 AM EDT
Location: Melbourne, Australia
Posts: 2,185
Thanks: 3
Thanked 24 Times in 23 Posts
Quote:
Originally Posted by ooilinlove View Post
sun = /bin/ksh
linux = /bin/ksh
Hi,

Did you try adding #!/bin/bash to the top of your script when running under Solaris, and trying again?

Whilst your shell may be /bin/ksh , that's not what is necessarily interpreting your script unless you explicitly state your interpreter with a shebang.

Cheers,
ZB
Sponsored Links
    #6  
Old 01-30-2013
Scrutinizer's Avatar
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 24 July 2014, 4:49 PM EDT
Location: Amsterdam
Posts: 9,281
Thanks: 260
Thanked 2,303 Times in 2,066 Posts
This is not valid syntax in any shell:

Code:
for count=0; count<arrlen; count++ ; do

Sponsored Links
    #7  
Old 01-30-2013
ooilinlove's Avatar
ooilinlove ooilinlove is offline
Registered User
 
Join Date: Aug 2008
Last Activity: 17 April 2014, 8:42 AM EDT
Posts: 72
Thanks: 7
Thanked 0 Times in 0 Posts
i try it.
but not work.

---------- Post updated at 06:16 PM ---------- Previous update was at 06:11 PM ----------


Code:
SunOS Proton 5.8 Generic_Virtual sun4u sparc SUNW,SPARC-Enterprise


Code:
#!/usr/bin/ksh

error : syntax error at line 12: `arr=' unexpected

Code:
#!/usr/bin/sh

error : syntax error at line 12: `arr=' unexpected

Code:
#!/usr/bin/bash

error : syntax error near unexpected token `(('
: line 20: `for ((count=0; count<arrlen; count++)) ; do'
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
[?] Does Netflix work on Linux in Firefox? KenJackson What is on Your Mind? 4 03-22-2012 08:58 PM
Help gettgin this script to work on linux binary-ninja Shell Programming and Scripting 4 08-23-2011 11:24 AM
Script doesn't work, but commands inside work cheongww UNIX for Dummies Questions & Answers 2 11-14-2006 09:52 PM
Work on Linux Using Bootable CD ?? newbie07 UNIX for Dummies Questions & Answers 2 04-25-2006 12:48 AM
ISDN on Linux..will it work? Phaelanx UNIX for Dummies Questions & Answers 4 03-01-2002 11:59 AM



All times are GMT -4. The time now is 11:09 AM.